I use some code working nicely on Rails 3 but not on Rails 4, I guess it is caused by Turbolinks but I don\'t know much about it, can\'t dig more deep to solve my problem, h
Solved this by moving = javascript_include_tag "application", "data-turbolinks-track" => true
from body to head, thanks all your help
You can leave it in the body, you just need to add to your script tag:
"data-turbolinks-eval" => false
In general, with turbolinks, it's best to make sure your code is "idempotent", so if it runs more than once, bindings won't get setup more than once.
The best way to do this is instead of $('blah').bind(), call unbind first:
$('blah').unbind('click').bind('click', function() {
One possible reason you could be running into issues is if you are including the js on every page. It's my understanding it will append the js to the head and if you have included it on multiple pages you could find yourself binding the ajax multiple times. That being said it's not apparent how you are including the js from what I saw. You could possibly solve this by only including the js file in your application.js