1. #1
    Sencha Premium Member d.zucconi's Avatar
    Join Date
    Jun 2008
    Location
    Piacenza (Italy)
    Posts
    79
    Vote Rating
    5
    d.zucconi is on a distinguished road

      0  

    Question Call Ext.onReady twice

    Call Ext.onReady twice


    Hi all,

    I have a question about Ext.onReady.
    My HTML pages are built using different templates (one main template for page header section and many others templates to produce body HTML content for each specific page). In the main (head) template I've my Ext inclusion <script> tags and a call to Ext.onReady to enable common widgets (such as page main menu that is the same for all pages).
    Now I'm trying to call Ext.onReady "again" (into the page body templates, it was called in the head section of the document) and apparently seems to work correctly (the result is the "sum" of the execution of the first and second onReady functions).
    The question is: is that a "correct" use of Ext.onReady ? Can I call it twice in my javascript code (in the head and then again in body to "add" other initialization functions ?)

    Thank you for your time

  2. #2
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    sure you can.

    all onReady() does is wait till the DOM is ready, following which it executes the passed function.

    if you call onReady() anytime after the DOM is ready, it'll just execute the passed function.
    pointless, but harmless.

  3. #3
    Sencha Premium Member d.zucconi's Avatar
    Join Date
    Jun 2008
    Location
    Piacenza (Italy)
    Posts
    79
    Vote Rating
    5
    d.zucconi is on a distinguished road

      0  

    Default


    Good !
    Thanks

  4. #4
    Ext JS Premium Member
    Join Date
    Feb 2010
    Location
    Vancouver, BC
    Posts
    194
    Vote Rating
    0
    rkim is on a distinguished road

      0  

    Default


    It is posted a long ago, but I would like to make sure one thing. What happens for the execution order. Sequential order guaranteed ? for example below example will always alert xx first ?

    <script>
    Ext.onReady(function()
    {
    alert("xx");
    });
    </script>
    <script>
    Ext.onReady(function()
    {
    alert("yy");
    });
    </script>

Thread Participants: 2