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 属性就有效...
奇怪了....
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
先看看你是否加载了
jquery_ujs.js文件。如果没有的话,估计是你改模板删了javascript_include_tag或者没有在 application.js 里写//=require jquery_ujs。