开发者

Rails 3 + jQuery - Remote Forms, Not working as required

I was Using JQuery Tools Validator for my remote form in rails.js i just add this condition if($('form').data('validator').checkValidity()) to check form validation if its return true than Call Remote otherwise do nothing. It was working fine in Firefox 3 but after latest version of Firefox and Chrome its skip the validation and submit form remotely.

Default this

$('form[data-remote]').live('submit', function (e) {
        $(this).callRemote();
        e.preventDefault();
    });

My Fix for validation

$('form[data-remote]').live('submit', function (e) {
开发者_开发知识库 if($('form').data('validator').checkValidity())
    {
        $(this).callRemote();
    }
    e.preventDefault();
});

Is this has something to do with latest support for HTML5 Features in Browsers. if yes whats a solution of it. Urgently required help Thanks.


I know this isn't exactly an answer, actually isn't an answer at all, but ...

I'm having the very same problem and worse, jqueryTools itself is having the problem. Note that JQuery Tools Validation Demo is not working on FF4.

There is an open issue in git hub jquery tools


Once my form is loaded through remote call than $('form').attr('novalidate', 'novalidate'); attach this attribute to ignore Browser specific HTML5 validation..

$('form[data-remote]').live('submit', function (e) {
    if ($(this).data('validator')) 
        {
              if ($(this).data('validator').checkValidity()) 
              {
                  $(this).callRemote();
              }
        } 
        else 
        {

              $(this).callRemote();
        }
        e.preventDefault();
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜