jquery.validate + remote form = validations runs, remote form fails in IE7/8 #165

Closed
teohm opened this Issue May 24, 2011 · 3 comments

Comments

Projects
None yet
2 participants
@teohm

teohm commented May 24, 2011

Tested with:

  • JQuery 1.6.1
  • JQuery Vaidation 1.8.1
  • Rails UJS (commit: 2b5d458)

When submitting a remote form:

  1. the validation runs correctly,
  2. but submitHandler() runs twice.
  3. The form is submitted, but not through XHR.
  4. As a results, the whole page is refreshed after submit.

To reproduce the issue, run this link in IE7 or IE8 (works well on IE9 though)
http://teohm.github.com/quirks/jquery-validate-ujs-conflict/jquery-ujs-latest.html

It might be related to a closed issue #118.

I have documented the issue with more details in
http://teohm.github.com/2011/05/jquery-validation-rails-ujs-conflict-in-ie8

@JangoSteve

This comment has been minimized.

Show comment
Hide comment
@JangoSteve

JangoSteve May 24, 2011

Member

I'm not sure I understand the demo. In Chrome, Firefox 4, and IE7 under Windows XP, I get a javascript error in your submitHandler function on line 41 of the page, "'form' is undefined". Is the form.submit() line in submitHandler suppose to be doing something?

I'm trying to figure out if this is a bug in jquery-ujs, form.validate, or the custom js on the demo page. The relevant test (which passes in IE7 and IE8) in jquery-ujs I believe is this one.

Member

JangoSteve commented May 24, 2011

I'm not sure I understand the demo. In Chrome, Firefox 4, and IE7 under Windows XP, I get a javascript error in your submitHandler function on line 41 of the page, "'form' is undefined". Is the form.submit() line in submitHandler suppose to be doing something?

I'm trying to figure out if this is a bug in jquery-ujs, form.validate, or the custom js on the demo page. The relevant test (which passes in IE7 and IE8) in jquery-ujs I believe is this one.

@teohm

This comment has been minimized.

Show comment
Hide comment
@teohm

teohm May 25, 2011

Hi Steve, my mistake, thanks for pointed it out :-)

I rewrote the example. It turns out, the latest jquery-ujs works well with jquery.validate even in IE7/8. Here's the new example: http://teohm.github.com/quirks/jquery-validate-ujs-conflict/jquery-ujs-latest.html

In case anyone bumps into this issue again in future, here's a working example to use submitHandler together with the latest version of jquery-ujs:

$('#submit_form').validate({
  submitHandler: function(form) {
    // .. do something before submit ..
    $.rails.handleRemote( $(form) );  // submit via xhr
    //form.submit();                  // don't use, it submits the form directly
  }
});

so I will close this issue, since it's invalid.

teohm commented May 25, 2011

Hi Steve, my mistake, thanks for pointed it out :-)

I rewrote the example. It turns out, the latest jquery-ujs works well with jquery.validate even in IE7/8. Here's the new example: http://teohm.github.com/quirks/jquery-validate-ujs-conflict/jquery-ujs-latest.html

In case anyone bumps into this issue again in future, here's a working example to use submitHandler together with the latest version of jquery-ujs:

$('#submit_form').validate({
  submitHandler: function(form) {
    // .. do something before submit ..
    $.rails.handleRemote( $(form) );  // submit via xhr
    //form.submit();                  // don't use, it submits the form directly
  }
});

so I will close this issue, since it's invalid.

@teohm teohm closed this May 25, 2011

@JangoSteve

This comment has been minimized.

Show comment
Hide comment
@JangoSteve

JangoSteve May 25, 2011

Member

Awesome, glad you figured it out. Thanks for the update, Teo!

Member

JangoSteve commented May 25, 2011

Awesome, glad you figured it out. Thanks for the update, Teo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment