【发布时间】:2014-04-28 13:13:48
【问题描述】:
我正在使用 simple_form 在我的 rails 应用程序中构建一个搜索表单。
我认为的代码
= simple_form_for :principal, url: url_for(action: 'analyze', controller: 'principals', format: :js, dataType: 'script'), method: :get, remote: :true do |f|
= f.input :category_id, input_html: {name: :category_id }
=f.button :submit
analyze.js.erb 中的代码
alert("check");
在响应选项卡中显示alert("check");
但在请求完成后,它没有向我显示警报框。
【问题讨论】:
-
您能否向我们展示
analyze.js.erb的控制器操作以及您的控制器代码? -
通过在表单标签中添加 data-type: "script" 解决了这个问题。 = simple_form_for :principal, url: url_for(action: 'analyze', controller: 'principals'), method: :get, html: { data: {type: 'script'},remote: :true} do |f|
标签: javascript ruby-on-rails ruby utf-8 ruby-on-rails-4