[英]javascript only works on page reload (rails, turbolinks installed)
I have this link 我有这个连结
<%= link_to "contact", ecrire_message_path %>
That page contains: 该页面包含:
$(document).on('turbolinks:load', function(){
// some correct javascript here
});
The javascript doesn't work when I click on the link. 当我单击链接时,javascript无法正常工作。 It only works after page reloads. 它仅在页面重新加载后有效。
turbolink gem is installed and included. turbolink gem已安装并包含在内。
I don't know how to add to the link_to
element not to use turbolinks. 我不知道如何添加到link_to
元素以不使用涡轮链接。
Thanks 谢谢
You can use 您可以使用
<%= link_to "contact", ecrire_message_path, data: { turbolinks: false } %>
From official guide : 来自官方指南 :
If you want to disable Turbolinks for certain links, add a
data-turbolinks="false"
attribute to the tag: 如果要禁用某些链接的Turbolinks,请在标签中添加data-turbolinks="false"
属性:<a href="..." data-turbolinks="false">No turbolinks here</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.