Rails 4: how to use $(document).ready() with turbo-links

前端 未结 19 1872
忘了有多久
忘了有多久 2020-11-21 06:52

I ran into an issue in my Rails 4 app while trying to organize JS files \"the rails way\". They were previously scattered across different views. I organized them into separ

19条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-21 07:41

    I found the following article which worked great for me and details the use of the following:

    var load_this_javascript = function() { 
      // do some things 
    }
    $(document).ready(load_this_javascript)
    $(window).bind('page:change', load_this_javascript)
    

提交回复
热议问题