Notice: The Monaca & Onsen UI Community Forum is shutting down.

For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.

Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.

Incomplete tutorial for the "ons-page"



  • Hello, in the following tutorial
    The ons object
    at page 3/4 it is written
    "In this example we are using ons.ready(fn) which waits until the page is completely loaded before executing a callback function."
    In the JS code I do not see any

    ons.ready(fn)
    

    but only a

    document.addEventListener('init', function(event)
    

    The

    ons.ready(fn)
    

    must be inserted before the

    document.addEventListener('init', function(event)
    

    ? And must the

    ons.ready(fn)
    

    be used always, for any page like the

    $(document).ready(function(){
    

    for jQuery?

    Thanks


  • Onsen UI

    @tbrcrl Hi, thanks for reporting, we’ll update the tutorial info!
    ons.ready only works once, it’s like DOM ready event. If you want to initialize a page, use the init event just like is done in the tutorial.



  • Thanks. I need just one more clarification; If in the same .js file I have both jQuery code and Onsen code, shall I put the Onsen code inside the ons.ready and the jQuery code inside the DOM ready event? that is

    ons.ready(function() {
      // Onsen JavaScript code
    });
    
    $(document).ready(function(){
        // jQuery JavaScript code
    });
    

    Thanks


  • Onsen UI

    @tbrcrl I think you can use ons.ready for everything. It should be almost the same as $(document).ready, if not the same.