dropdowns only trigger once

匆匆过客 提交于 2020-01-17 10:38:09

问题


I have two filter dropdowns on this site which will only trigger the first time I press them. According to my studies it seems that it has to do with turbolinks, which I've disabled by adding data-no-turbolink to the body tag like so:

<body data-no-turbolink>
...
</body>

I've also tried adding this to all of the dropdown links and the link to open the dropdown.

<a href="some-link" data-no-turbolink>...</a>

It seems to work on development, but when I push to Heroku, it seems turbolinks are running again. Any suggestions?


回答1:


If Turbolinks is an issue, it can be removed entirely from the project by following the instructions provided e.g. here:

  1. remove gem 'turbolinks' from the Gemfile and run bundle update
  2. remove //= require turbolinks from app/assets/javascripts/application.js
  3. remove "data-turbolinks-track" => true from the stylesheet and javascript tags in the header of application.html.erb layout file.

Quoting Rails 4 In Action:

...it's our opinion that Turoblinks is great to speed up mostly-server-side sites, but as soon as you start writing some JavaScript, it causes more problems than it's worth.



来源:https://stackoverflow.com/questions/23606078/dropdowns-only-trigger-once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!