Ext 2-iframe bug

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

解决方法:

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

[b]第一个代码片段修改前[/b]

var fireDocReady = function(){
if(!docReadyState){
docReadyState = true;
Ext.isReady = true;
if(docReadyProcId){
clearInterval(docReadyProcId);
}
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();
}
}
};


[b]第一个代码片段修改后[/b]

var fireDocReady = function(){
if(!docReadyState){
docReadyState = true;
//Ext.isReady = true;
if(docReadyProcId){
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();
}
}
};


[b]第二个代码片段修改前[/b]

/**
* 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);
},

[b]第二个代码片段修改后[/b]

/**
* 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

官方原文地址:[url]http://www.sencha.com/forum/showthread.php?43246-2.2-FIXED-Ext.onReady-and-onLoad[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值