1

RoR2中,我们可以使用:

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

发出 ajax 请求并重新渲染对应的 div 或其他任何内容smthId


RoR3 remote_form_for中已弃用,因此:

form_for @something, :remote => true do |f| 

必须使用。


我的问题:是否有类似RoR3中的帮助程序的选项:update => {},或者每次需要重新渲染时都应该在控制器中触发 javascript 的方法?form_forsmthId

4

1 回答 1

1

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

 $("#new_something").bind('ajax:success', function(xhr, data, status){});
 $("#new_something").bind('ajax:error', function(xhr, data, status){});
于 2012-09-12T09:01:07.730 回答