View Full Version : multiple Ext.onReady. Order of execution?

11 Oct 2010, 11:18 AM
I tried to search for similar issues but couldn't find it, so:

* I have a page generated by multiple PHP pages
* As a result, I can have multiple Ext.onReady sections throughout the pages

What I expect is for the code of all those sections to be merged into one big block and executed once all the page has been loaded, or for all those blocks to be executed in the order they are encountered.

What I notice is:
* Only on Chrome (works fine on Firefox and IE): It seems that the blocks are mis-ordered and the second one get executed before the first one, i.e.:
First Ext.onReady on top of the page declares multiple functions
Second Ext.onReady later on uses one of those functions
==> In some cases (random), the second block is executed before and try to call a function not yet declared

I say random, as if I do a refresh of the page, it may work, then another one and it doesn't. Cannot predict.

Does any of you encounter that before? How can I solve that problem?

Thanks in advance for any ideas (that's a pretty annoying occurrence)


11 Oct 2010, 3:25 PM
If you are developing something like this, then you should be developing your own stack for "onReady" executions.

11 Oct 2010, 8:29 PM
Any other suggestions?

Typically, I just need two blocks:
1. Contains the declarations of the functions
2. Contains the calls

Those two blocks are generated by two different PHP files. I need 1 to be executed/interpreted before 2.

If I put 1 in a JS file included at the top of the main PHP file, does it guarantee it's execution before anything else?

11 Oct 2010, 8:37 PM
write and execute all your declarations functions (1) outside "onready" like extjs do itself
write "calls method" (2) inside "onready" block

11 Oct 2010, 9:31 PM
Declarations of functions do not need to be in an onReady.

onReady is only necessary to delay code which needs to access the DOM.