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

前端 未结 7 1091

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:55

    Here's what I do.. Turbolinks5 to prevent loaded multiple times.

    var ready = function () {
    
       if ($.turboAlreadyLoaded) {
    
          $('#screen-selection').chosen({
            width: '190px'
          })
       }
    $.turboAlreadyLoaded = true;
    
    }
    $(document).ready(ready);
    $(document).on("turbolinks:load", ready);
    

提交回复
热议问题