ant*_*tor 6 ajax jquery ujs ruby-on-rails-3
我正在尝试触发ajax:远程链接的成功回调.我在Rails 3.0.8和jquery-rails 1.0.11上.我运行了jquery生成器来安装javascripts.jquery和jquery_uj都包含在我的默认值中,我可以验证它们是否包含在页面中.
这是我的javascript:
jQuery(function($) {
$("#deactivate")
.bind("ajax:success", function() {
alert("HELLO");
})
.bind("ajax:error", function() {
alert("GOODBYE");
}
);
});
Run Code Online (Sandbox Code Playgroud)
链接:
= link_to 'Deactivate', activate_patient_path(patient), :id => 'deactivate', :class => "button button-red", :remote => true
Run Code Online (Sandbox Code Playgroud)
激活动作:
def activate
patient = Patient.find(params[:id])
patient.do_not_call = !patient.do_not_call
if patient.save
render :nothing => true
else
render :status => 500, :nothing => true
end
end
Run Code Online (Sandbox Code Playgroud)
ajax调用似乎工作正常.触发操作,我可以看到数据库中的更改.但是,没有触发ajax回调.我不能让他们中的任何一个工作.我可以获得其他事件,例如点击,以便完美地工作.
如果我在Firebug中调试rails_ujs,我会看到以下代码从Rails ajax块运行:
success: function(data, status, xhr) {
element.trigger('ajax:success', [data, status, xhr]);
}
Run Code Online (Sandbox Code Playgroud)
我很难过.有任何想法吗?
| 归档时间: |
|
| 查看次数: |
5135 次 |
| 最近记录: |