I have a Rails app, I recently updated to 5.0.0.RC1
. Most of the transition went smooth, but I\'m having some trouble with the new Turbolinks. In my app I for e
With turbolinks the javascript is only loaded once. On the hard refresh chosen
works because the entire page is re-rendered. Once you click a link, turbolinks hijacks the request and turns it into an ajax one (instead of a full page refresh). Once the request comes in, turbolinks only replaces the body
of the page, leaving the JS in the same state it was.
To fix this you will need to wrap your chosen initializer in the turbolinks:load
event like so
$(document).on('turbolinks:load', function() {
$('#screen-selection').chosen({
width: '190px'
})
})
For more information, see https://github.com/turbolinks/turbolinks#installing-javascript-behavior