0
我可以在表单中提交我的表单,并且由ajax成功发送。但我想用JS显示响应(成功或错误),但我不能。Rails 4 remote true and response js
这里是我的表单+ JS:
= simple_form_for @widget, :url=> template_save_widget_manager_template_url(id:widget.id),:format => :js, remote: true do |f|
= f.input :title, label: "Titre ?"
= f.input :active, label: "Titre ?"
= f.input :where, label: "Ou souhaitez-vous afficher ce bloc ?", collection: @where
= f.button :submit, class:'btn btn-primary'
- content_for :script do
javascript:
$(document).ready(function(){
$("#new_clan_templates_widgets_build").on("ajax:success", function (e, data, status, xhr){
alert('test');
});
})
在我控制我已经中庸之道添加render false
。
JavaScript代码不起作用,为什么?
你应该把它里面create.js.erb –
是的,我已经试过i'have放“警报(‘测试’);付诸行动.js.erb,但它不工作。与Chrome我有“网络”响应纯文本“警报(”测试“)”:/ – Shinix