Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extjs 4 - Button menu item click

Tags:

extjs4

I have a menu for a button, which in turn is set as the tools for a container. I want to handle click on the menu items and not on the button itself. How do I implement it?

like image 265
Rutwick Gangurde Avatar asked Mar 20 '23 18:03

Rutwick Gangurde


1 Answers

You can handle all items in a listener through a code below. Pass a menu config to a button and add a click listener to the menu.

{
    xtype: 'button',
    text: 'Button',
    menu: {
        xtype: 'menu',
        items: [
            { text: 'foo' },
            { text: 'bar' },
            { text: 'hoge' }
        ],
        listeners: {
            click: function( menu, item, e, eOpts ) {
                console.log(item.text);
            }
        }
    }
}
like image 164
Kohei Mikami Avatar answered Apr 30 '23 05:04

Kohei Mikami