JS方法中未定义的局部变量或方法“清单”

时间:2019-06-05 20:18:43

标签: javascript jquery ruby-on-rails-5.2

我有一个称为index.js的JS视图。但是,我想将代码index.js代码放入JS帮助器中。我将此代码放入AfterSearchSubmit()方法中。但是,出现以下错误。我该如何解决?

index.js

(function(){
  var html = "<%= j(render(:partial => 'search/searchresults.html.erb', :locals=>{:listings => @listings})) %>"
    $('#listings').html(html);

})();

我想转换为JS Helper ...

资产/javascript/search_form.js

  AfterSearchSubmit(mylistings){
    var html = "<%= j(render(:partial => 'search/searchresults.html.erb', :locals=>{:listings => mylistings})) %>"
    $('#listings').html(html);
  }

控制器:

respond_to do |format|
  format.js {Helpers.SearchForm.AfterSearchSubmit(@listings)}
en

错误: #<#:0x00007f84ffc2f6b0>

的未定义局部变量或方法“列表”

0 个答案:

没有答案