After experimenting with the latest jquery-ujs and making an embarrassing mistake, it turns out that the issue is resolved in the latest version.
(Mistake: You may notice I removed a previous post about this topic, where I mistakenly concluded the latest jquery-ujs is not working with JQuery Validation. Thanks to JangoSteve for pointing it out. The post was misleading, so I believe it’s best to remove it to avoid confusion. :-)
Get the latest
There are 2 reasons to use the latest jquery-ujs:
- it has a patch that fixes the issue (see issue #118).
- it exposes an internal function that we may need –
$.rails.handleRemote()(see more details)
The example is tested with:
- JQuery 1.6.1
- JQuery Vaidation 1.8.1
- Latest Rails UJS (commit: dad6982dc592686677e6)
submitHandler in JQuery Validation
If you are using JQuery Validation’s
submitHandler(form) function, you need to
$.rails.handleRemote( $(form) ) function manually, so that it submits the form via XHR.