Welcome Guest, Not a member yet? Register   Sign In
[solved] don't understand javascript variable scope; now talking about validation plugin
#9

[eluser]SPeed_FANat1c[/eluser]
[quote author="Fabdrol" date="1296066516"]where's the "invalid" message (next to the field) set? does that happen inside the form plugin?
I'm not sure about this, since I don't know that plugin, but I think it works like this:

1. Checks remote source if the form field is valid
2. In the callback of the ajax method (inside the plugin) it attaches the warning to the field
3. The variable "valid" doesn't get populated with false, but either with true, undefined or the original object, if chaining is enabled.

You can check it as this:
Code:
window.console.log(valid) // check the contents of valid in Firebug
if(valid === true) // make sure valid doesn't just exist, it's also actually true
    alert('foo');

Now, if you can post the result of console.log here, I think I can give you a definite answer.[/quote]

Plugin generates the message:

<label for="input_pavadinimas" generated="true" class="error">Please fix this field.</label>

and puts it right after the input field.

In the console I get:

true
XHR finished loading: "http://www.ylakiudarzelis.lt/admin_/info_psl/name_check_ajax?input_pavadinimas=asdasd".

and the foo is alerted.

But I gues I see the problem - it is with that asynchronious thing again. It first returns true, but requst is not finished yet.

Still don't understand then what is the point of the remote validation if it is asyncronoius? It should always wait till request is fishished and then assign value.


Messages In This Thread
[solved] don't understand javascript variable scope; now talking about validation plugin - by El Forum - 01-26-2011, 06:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB