Ext 2-iframe bug

在Ext2.0 Beta1中 在嵌套iframe时出现Ext.getBody() 返回undefined现象,经过排查,发现是js的执行顺序问题,Ext.onReady被过早的执行。继续寻求答案,最后发现这应该是Ext的一个bug。

解决方法:

修改EventManager.js
主要分为两个代码片段:

第一个代码片段修改前

var fireDocReady = function(){
        if(!docReadyState){
            docReadyState = true;
            Ext.isReady = true;
            if(docReadyProcId){
                clearInterval(docReadyProcId);
            }iphone5
            if(Ext.isGecko || Ext.isOpera) {
                document.removeEventListener("DOMContentLoaded", fireDocReady, false);
            }
            if(Ext.isIE){
                var defer = document.getElementById("ie-deferred-loader");
                if(defer){
                    defer.onreadystatechange = null;
                    defer.parentNode.removeChild(defer);
                }
            }
            if(docReadyEvent){
                docReadyEvent.fire();
                docReadyEvent.clearListeners();
            }
        }
    };

第一个代码片段修改后

var fireDocReady = function(){
        if(!docReadyState){
            docReadyState = true;
            //Ext.isReady = true;           
            if(docReadyProcId){nvocc
                clearInterval(docReadyProcId);
                docReadyProcId = null;
            }
            if(Ext.isGecko || Ext.isOpera) {
                document.removeEventListener("DOMContentLoaded", fireDocReady, false);
            }
            if(Ext.isIE){
                var defer = document.getElementById("ie-deferred-loader");
                if(defer){
                    defer.onreadystatechange = null;
                    defer.parentNode.removeChild(defer);
                }
            }
            if(docReadyEvent && !Ext.isReady){
                Ext.isReady = true;
                docReadyEvent.fire();
                docReadyEvent.clearListeners();
            }
        }
    };

第二个代码片段修改前

/**
         * Fires when the document is ready (before onload and before images are loaded). Can be
         * accessed shorthanded as Ext.onReady().
         * @param {Function} fn The method the event invokes
         * @param {Object} scope (optional) An object that becomes the scope of the handler
         * @param {boolean} options (optional) An object containing standard {@link #addListener} options
         */
        onDocumentReady : function(fn, scope, options){
            if(docReadyState){ // if it already fired
                docReadyEvent.addListener(fn, scope, options);
                docReadyEvent.fire();
                docReadyEvent.clearListeners();
                return;
            }
            if(!docReadyEvent){
                initDocReady();
            }
            docReadyEvent.addListener(fn, scope, options);
        },

第二个代码片段修改后

/**
         * Fires when the document is ready (before onload and before images are loaded). Can be
         * accessed shorthanded as Ext.onReady().
         * @param {Function} fn The method the event invokes
         * @param {Object} scope (optional) An object that becomes the scope of the handler
         * @param {boolean} options (optional) An object containing standard {@link #addListener} options
         */
        onDocumentReady : function(fn, scope, options){
            if(docReadyState){ // if it already fired
                docReadyEvent.addListener(fn, scope, options);
                docReadyEvent.fire();
                docReadyEvent.clearListeners();
                return;
            }
            if(!docReadyEvent){
                initDocReady();
            }
            options = options || {};
            if(!options.delay){
                options.delay = 1;
            }
            docReadyEvent.addListener(fn, scope, options);
        },

修改之后,问题解决。
IE版本:IE8
Ext版本:Ext2.0 Beta1

posted @ 2011-06-21 10:07  sky7034  阅读(280)  评论(0编辑  收藏  举报
蘑菇街女装 货运专家