ExtJs bubble menu event

I have my ExtJs menu defined as follows. I have two custom methods added to my menu item 'hookMethod' and 'handlerMethod'. 'hookMethod' is added based upon some condition. I bubble the click event for individual menu items to the root menu. Then checks if hook is defined then call 'hookMethod' else call the 'handlerMethod' directly. The problem that I am facing is that the click listener is called twice, once for menuitem and once for menu. Also, what is e argument. I was thinking it will be called only once for menu and I will have some way to retrieve the actual menu item being clicked in it.

{
    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
        },
    }]
}

Ext.menu.Menu click( menu, item, e, eOpts ) event have four parameters.

First parameter is menu object itself.

Second item parameter is object of the menu item that was clicked. This parameter you can use for determine which item in menu was clicked.

链接地址: http://www.djcxy.com/p/19548.html

上一篇: Ext.util.Observable.observe中的ExtJS调用控制器方法

下一篇: ExtJs泡泡菜单事件