如果我的控制器是page_controller.rb,并且资产下的关联javascript文件是page.js,那么当我使用re_direct时,page.js中的任何内容都不会重新加载
我尝试了以下
redirect_to page_path, data: { no_turbolink: true }
但是它没有用,尽管可以通过link_to正常工作
link_to 'page title', page_link, data: { no_turbolink: true }
任何想法?
编辑:
我的内容如下index.html.haml
:
%li
= link_to status, page_status_path({param1: hello, param2: hello2})
在我的控制器中,我有:
def index
....
end
def status
redirect_to index_path, data: { no_turbolink: true }
end
现在,我知道turbo链接路径没有意义,但是当我重定向回索引时如何加载javascript?
当您逐页浏览时,Turbolinks不会加载某些js文件(这是因为绑定事件的节点不再存在。),但是此gem解决了该问题。
gem "jquery-turbolinks"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句