首页 > rails 中ujs data-remote 属性无效

rails 中ujs data-remote 属性无效

erb的代码是这样的:

<%= link_to 'Edit',some_path(1, format: :js), remote: true%>

生成的是

<a data-remote="true" href="/some_path/1.js">Edit</a>

但是点击这个链接就跳转了,并没有发起 AJAX 请求...

这个 a 标签也是通过 ujs 生成的;但是a 标签上方有个form, data-remote 属性就有效...
奇怪了....


先看看你是否加载了 jquery_ujs.js 文件。如果没有的话,估计是你改模板删了 javascript_include_tag 或者没有在 application.js 里写 //=require jquery_ujs

【热门文章】
【热门文章】