Fix JavaScript to adapt to turbolinks.