Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs 菜单中的fireEvent侦听器错误_Extjs_Scope_Dom Events_Extjs3 - Fatal编程技术网

Extjs 菜单中的fireEvent侦听器错误

Extjs 菜单中的fireEvent侦听器错误,extjs,scope,dom-events,extjs3,Extjs,Scope,Dom Events,Extjs3,cfg作为函数的一个参数。都在那里。 log工作-因此,在该点之前的代码也工作。 这似乎在正确的范围内 然而,fireEvent的结局是: 未捕获的TypeError:无法读取未定义的属性“apply” 在错误日志中的调用之后,fireEvent确实得到执行,它到达 return new Ext.Button({ text: cfg.text, menu: { xtype: 'menu', items: cfg.menu, listeners: { i

cfg作为函数的一个参数。都在那里。 log工作-因此,在该点之前的代码也工作。 这似乎在正确的范围内

然而,fireEvent的结局是:

未捕获的TypeError:无法读取未定义的属性“apply”

在错误日志中的调用之后,fireEvent确实得到执行,它到达

return new Ext.Button({
  text: cfg.text,
  menu: {
    xtype: 'menu',
    items: cfg.menu,
    listeners: {
      itemclick: {
        fn: function() {
          console.log(this);
          this.fireEvent('tabchange', 'apps');
        },
        scope: this
      },
      scope: this
    },
    scope: this
  },
  minWidth: 50,
  scope: this
});
这就是它失败的地方

尝试在事件侦听器内调用事件时是否存在某种范围/嵌套问题


我的目标是在按钮的菜单项选择上触发该事件。

显然是由于未定义的处理程序

处理程序是使用

这是我的


在超类init之前的initComponent中。

您是否使用断点检查了作用域?如果我在每个步骤中都专门添加了作用域,那么作用域最终可能还是错误的?如果我没有添加范围:this-我只会得到未定义的fireEvent。我也可以通过它访问其他变量和函数。我假设fireEvent在该类中查找自定义事件时仍然超出范围,并且找不到它。事件在initComponent中设置为this.addEvents。fireEvent上的断点确实显示了此事件的适当范围,并且列出了该事件。啊,通过分步调试,似乎有一个侦听器未定义。这仍然让我感到困惑,因为如果它在diff按钮处理程序中,同样的事件可以很好地工作。
EXTUTIL.Event.fire
 if(l && l.fireFn.apply(l.scope || me.obj || window, args) === FALSE)