问题
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:
- remove
gem 'turbolinks'
from the Gemfile and runbundle update
- remove
//= require turbolinks
from app/assets/javascripts/application.js - remove
"data-turbolinks-track" => true
from thestylesheet
andjavascript
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