开发者

Rails 3: Show validation errors for simple_form with ajax

I am using rails3 with simple_form gem and :remote=>true (开发者_如何学JAVAajax).

How to I show validation error with :remote=>true?

Thanks


Use the javascript rails callbacks to do this.

See how do this here: http://www.simonecarletti.com/blog/2010/06/unobtrusive-javascript-in-rails-3/


My approach with this situation (validation errors on ajax submission) has been to pack up the errors off the form and handle them client side. I have been doing all my data using JSON so I send them back as a hash of input => long message. The input id allows me to easily turn on the form input "red" and the long message goes wherever you're putting the generalized messages...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜