extjs4.1中出现Cannot read property 'fn' of undefined的错误
来源:互联网 发布:数据采集器工作原理 编辑:程序博客网 时间:2024/06/05 16:33
当给controller添加监听器(addListener)时,有时候会出现莫名其妙的错误:
比如 Cannot read property 'fn' of undefined,此时如果代码比较多的时候,不太好找错误,
此时可以用如下方法:
在 Ext.util.Observable中捕获错误的详细信息,添加红色代码即可,这样就可以找到错误原因了
addListener: function(ename, fn, scope, options) {
var me = this,config, event, hasListeners,
prevListenerCount = 0;
if (typeof ename !== 'string') {
options = ename;
for (ename in options) {
if (options.hasOwnProperty(ename)) {
config = options[ename];
if (!me.eventOptionsRe.test(ename)) {
if (typeof(config) == 'undefined') {
console.error('Cannot bind to event "' + ename + '" - method does not exist on object', options.scope);
} else {
me.addListener(ename, config.fn || config, config.scope || options.scope, config.fn ? config : options);
}
}
}
}
} else {
ename = ename.toLowerCase();
event = me.events[ename];
if (event && event.isEvent) {
prevListenerCount = event.listeners.length;
} else {
me.events[ename] = event = new Ext.util.Event(me, ename);
}
// Allow listeners: { click: 'onClick', scope: myObject }
if (typeof fn === 'string') {
//<debug>
if (!(scope[fn] || me[fn])) {
Ext.Error.raise('No method named "' + fn + '"');
}
//</debug>
fn = scope[fn] || me[fn];
}
event.addListener(fn, scope, options);
// If a new listener has been added (Event.addListener rejects duplicates of the same fn+scope)
// then increment the hasListeners counter
if (event.listeners.length !== prevListenerCount) {
hasListeners = me.hasListeners;
if (hasListeners.hasOwnProperty(ename)) {
// if we already have listeners at this level, just increment the count...
++hasListeners[ename];
} else {
// otherwise, start the count at 1 (which hides whatever is in our prototype
// chain)...
hasListeners[ename] = 1;
}
}
}
- extjs4.1中出现Cannot read property 'fn' of undefined的错误
- [jQuery]Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
- [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
- [JQUERY] CANNOT READ PROPERTY ‘MSIE’ OF UNDEFINED错误的解决方法
- Extjs4.0中的Uncaught TypeError: Cannot read property 'isEvent' of undefined错误
- Extjs4---Uncaught TypeError: Cannot read property ‘items’ of undefined
- extjs4:Uncaught TypeError: Cannot read property 'processed' of undefined
- jqgrid 4.8版本 Cannot read property 'decimalSeparator' of undefined 错误
- JS: Cannot read property 'innerHTML' of undefined错误
- Uncaught TypeError: Cannot read property 'options' of undefined 错误
- 错误:Uncaught TypeError: Cannot read property 'WebSocket' of undefined
- ExtJS错误解决 Cannot read property 'on' of undefined
- qml TypeError: Cannot read property 'xxx' of undefined 错误处理
- Jquery错误:Cannot read property ‘msie’ of undefined
- PIC单片机之定时器(TMR0)
- EJB调用原理分析 (飞茂EJB)
- Can you solve this equation?(二分查找的简单应用)
- linux yum 安装apace mysql php
- CentOS安装Wine-1.5
- extjs4.1中出现Cannot read property 'fn' of undefined的错误
- 字节流与字符流的区别(good!)
- TOMCAT学习笔记
- 泥污识别
- ASP JSP HPH区别 及 编写和使用JavaBeans
- Eclipse常用设置
- qq2013 聊天纪录存放路径 及 导入聊天记录
- Java NIO学习8(Selector 补充版ServerSocketChannel)
- 标准串口定义-9转25的串口线接法图