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

前端 未结 19 1543
忘了有多久
忘了有多久 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:39

    Instead of using a variable to save the "ready" function and bind it to the events, you might want to trigger the ready event whenever page:load triggers.

    $(document).on('page:load', function() {
      $(document).trigger('ready');
    });
    

提交回复
热议问题