开发者

Rails 3: Clearing errors from a form

开发者 https://www.devze.com 2023-03-14 10:44 出处:网络
First of all, I\'m using rails 3.0.8 with devise and ClientSideValidations. I have a form (user sign-up) appearing in a modal window.

First of all, I'm using rails 3.0.8 with devise and ClientSideValidations.

I have a form (user sign-up) appearing in a modal window. In that modal window I have a cancel button that closes it and reset the form, via JQuery.

If I press th开发者_运维百科at cancel button everything works fine, except that if I open the form again the validation errors ,from before closing the form, still exists.

Error_messages.clear doesn't work. I thought about creating the form when the modal pops up and deleting it when it closes but I'm not that familiar with JS.

Anyway,I hope for some JS magic from someone expert. And excuse my english.


What I do in my app is just empty the messages once the cancel button is clicked. Like this:

$('.modalform .close').click(function(){
    $(this).parents('.modalform').fadeOut();
    $(".error").empty();
});
0

精彩评论

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