npm更新后没有触发jQuery事件

时间:2016-06-08 15:11:28

标签: javascript jquery ruby-on-rails ajax

我正在处理一个应用程序。在我使用jquery_ujs gem之前,现在切换到通过npm(webpack)使用它。切换后,当应用程序发出put / post请求时,它正在发出成功请求(我可以通过控制台确认)但是ajax:success和ajax:error不会在

上触发
$(document).on('ajax:success', ‘.test', function(event, xhr){
//code
});

我尝试使用:

$(document).ajaxSuccess(‘.test’, function(event,xhr){
//code
}

1 个答案:

答案 0 :(得分:0)

根据the documentation,应该是:

$(document).ajaxSuccess(function(event, xhr){
  //code
});

$(document).ajaxSuccess('.test', function(event, xhr){
  //code
});
相关问题