How can I trigger "page ready" via jQuery?


  • Hey!

    I have some jQuery scripts on my theme which works fine.

    But if I reload the page via the refresh button, the script doesn't load.

    currently I am using:

    $(document).ready(function() {
    //CODE
    }
    

    Which is fine if I click inside the forum. But when I try to reach the direct URL, the script does not execute. As well (as meantioned) If i reload the page.

    I tried it with the following listeners:

    $(window).on('action:ajaxify.end', function(event, data) {
      //CODE
    });
    
    $(window).on('action:ajaxify.dataLoaded', function(event, data) {
      //CODE
    });
    
    $(window).on('action:posts.loaded', function(event, data) {
      //CODE
    });
    

    Same probem. If I reload the page, it doesn't work. If I call the URL directly, it doesn't work.

    If I surf inside the forum, it works.

    Whats the problem?

  • Admin Staff

    How are you including the scripts in your forum?


  • @baris I include the script with

    <script></script>
    

    This happens trough a created template.

    The template is imported after the posts.tpl in the topic.

  • Admin Staff

    That should work I think, you can also try putting your scripts in the ACP at /admin/appearance/customise#custom-js

Suggested Topics

  • 8
  • 2
  • 2
  • 2
  • 8
| |