Ext.onReady() vs $(document).ready()

后端 未结 3 713
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-15 11:54

Whats the difference? I have on $(document).ready function which should check if extjs is loaded but the main problem is extjs does not load on time and things inside $(document

3条回答
  •  攒了一身酷
    2021-02-15 12:18

    No they're not the same, the first one will proc when your jQuery library is loaded, the Ext.onReady(.. will proc when your ExtJS library is loaded.

    If you want to combine them you could do something like this:

    var extReady = false;
    var jQueryReady = false;
    
    var librariesReady = function () {
        if (jQueryReady && extReady) {
            //They're both ready
        }
    };
    
    $(document).ready(function () {
        jQueryReady = true;
        librariesReady();    
    });
    Ext.onReady(function () {
        extReady = true;
        librariesReady();
    });
    

提交回复
热议问题