【发布时间】:2014-02-18 07:00:03
【问题描述】:
我的 ExtJs 菜单定义如下。我在菜单项“hookMethod”和“handlerMethod”中添加了两个自定义方法。 'hookMethod' 是根据某些条件添加的。我将单个菜单项的单击事件冒泡到根菜单。 然后检查是否定义了钩子,然后调用“hookMethod”,否则直接调用“handlerMethod”。我面临的问题是点击监听器被调用了两次,一次用于 menuitem,一次用于菜单。另外,什么是 e 论点。我在想它只会为菜单调用一次,我将有一些方法来检索在其中单击的实际菜单项。
{
xtype: "menu",
listeners: {
click: function(item, e, eopts)
{
if(item.hookMethod) {
item.hookMethod(item.handlerMethod);
}
else {
item.handlerMethod(this);
}
}
},
items: [{
xtype: "menuitem",
text: "Process Record",
bubbleEvents: ['click'],
hookMethod: function(actualMethod)
{
//do some pre-processing here and then call the actual handler
actualMethod(args)
},
handlerMethod: function(args)
{
//Do actual processing
},
}]
}
【问题讨论】:
标签: extjs