开发者

Rails 3: Clearing errors from a form

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜