Search code examples
extjsonready

EXTJS - Ext.require and onReady() for inner scripts


I have an app.js file which is loaded from main html file. Now this app.js file upon click of links defined in it, dynamically loads second js file using Ext.require(). Loading happens ok as I have defined Ext.Loader.setPath() etc, the second script contains lines such as Ext.require() to import some ui libraries and followed by onReady(), my problem is onReady is never fired, and I cannot put widget rendering code outside onReady(). does onReady works only for synchronous loading of scripts?

Thanks much


Solution

  • onReady will only ever fire a single time for your application.

    If you look at the docs you'll see Ext.require() can take a callback function:

    Ext.require('My.foo.Bar', function() {
        console.log('do something');
    });
    

    http://docs.sencha.com/extjs/4.2.0/#!/api/Ext-method-require