Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
rails ujs driver + jquery-validation + ajax form - causes validation to be silently ignored (only IE) #118
not clear to me whether the problem is with the ujs driver or jquery-validate...
when using jquery UJS driver (most recent) and an ajax form (via the data-remote tag), the validation rules are silently ignored. only in IE 8, chrome and FF work fine
tested with jquery 1.4.4 and jquery 1.5.1, using most recent jquery-validation from github.
here is a simple example:
I glanced through the source code of the jquery-validation plugin (I assume you're referring to this one), and it appears this is not resolvable from the jquery-ujs end; it would require a change to the jquery-validation plugin.
We can see on this line of the validation plugin, it triggers the validation from the form's submit event. However, the entire purpose of jquery-ujs is to submit the form via ajax, which bypasses the standard form submission and page refresh.
The best solution all around, would be if Jörn (the author of the validation plugin) allowed the validation trigger to be configurable, so that the validation could be triggered from any event. Then you could trigger validation with jquery-ujs's
I'd consider starting a ticket over there asking for this feature or pointing to this ticket.
Oh interesting. I missed the part about this being an IE-only problem. I'm probably wrong then. In fact, now that I think about it, the form submit binding from the validation plugin should be triggered before it bubbles to the document node, where rails.js is triggered.
It sounds like this may be related to the IE submit bubbling issue that I mentioned on your other ticket. Any chance you can try this with the rails.js from this fork and see if that works?
EDIT: The reason this may work is because, it may be that the validation is canceling the event, but that jQuery is still manually triggering the form submission in IE, which is explained in that pull request. Just a guess though.
steve, thanks. i tested your patched rails.js, and it did not work. here is the example - http://avioing.com/validate/example.iefix.html
the example is dead simple, it's a two field form, and the only include files are jquery, ujs and jquery-validate. feel free to play with it