RoR3:ajax form_for

时间:2012-09-12 08:26:05

标签: ruby-on-rails ruby-on-rails-3

RoR2 中我们可以使用:

remote_form_for "something", :update => {:success => "smthId", :failure => "errors"} do |f|

发出ajax请求并使用smthId重新发送通讯div或其他内容;


RoR3 remote_form_for已被弃用,因此:

form_for @something, :remote => true do |f| 
必须使用

<小时/> 我的问题:  对于 RoR3 中的:update => {}助手,是否有form_for选项,或者每次需要重新呈现smthId时,应在控制器中触发javascript的方法?

< / p>

1 个答案:

答案 0 :(得分:1)

rails 3中没有更新选项。 你可以像下面这样使用它:

 $("#new_something").bind('ajax:success', function(xhr, data, status){});
 $("#new_something").bind('ajax:error', function(xhr, data, status){});