Remote true on button_to not进行ajax调用
remote true on button_to not makes ajax call
我正在做一个小的rails应用程序。
我正在尝试进行ajax调用。尽管我使用remote: true
的button_to是一个非ajax请求。它重定向到这个url http://localhost:3000/lines?product_id=1
<% @products.each do |product| %>
<%= link_to product.name, controller: "store", action: "show", id: product %><br>
<%= button_to "Add to Cart", {controller: "lines", action: "create", product_id: product.id}, method: "POST", remote: true %>
<% end %>
github回购
任何想法?
谢谢!
——编辑这是我的application.js
= require jquery
= require jquery_ujs
//= require turbolinks
//= require_tree .
这样的问题通常是因为你没有正确加载jquery。button_to ... remote: true
变成ajax调用,因为remote: true
触发javascript,改变按钮的行为。
在你的application.js
中,你需要javascript:
= require jquery
= require jquery_ujs
应该是:
//= require jquery
//= require jquery_ujs
正确加载jquery后,您应该会得到按钮的行为如预期的
相关文章:
- 为什么不't Javascript对我的输入值进行了一些重新检查
- 使用agility.js进行页面布局和合成
- 如何使用skip参数使用angular ui引导进行服务器端分页
- JavaScript数组排序(函数)用于对表行进行排序,而不是排序
- 借助asp.net验证或java脚本对多个文本进行验证
- 使用promise和mongoose对文档进行排序
- Selectize.js:如何对整数值的选项进行排序
- 在Safari执行javascript之前对其进行修改
- React组件等待所需道具进行渲染
- 单击顶部导航时如何进行向下滚动效果(向下滑动).
- 使用html中的外部javascript进行数据验证
- 如何在javascript上使用flak-babel进行翻译
- 如何通过引用var Using DataTables来进行分页或排序
- $rootScope未使用forEach进行更新
- jQuery is not loaded
- AngularJS JSON not arriving php
- 有没有一个javascript图形绘制库可以进行气球树布局
- 在数据提取完成之前进行页面渲染
- JQuery对动态创建的对象进行选择
- Remote true on button_to not进行ajax调用