Rails 5 - turbolinks 5,some JS not loaded on page render

前端 未结 7 1054

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

7条回答
  •  有刺的猬
    2020-12-30 08:57

    Turbolinks and jquery are kinda headache. Instead of calling an action on document ready, on page:load should work better, 'cause with turbolinks, it doesn't reload the entire documment when you browse the website. Something like this may work:

    $(document).on('page:load', function() {
      $('#screen-selection').chosen({
        width: '190px'
      })
    }
    

提交回复
热议问题