Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

click listener for tab panel in EXTJS

i use a tab panel in extjs. I want to display an alert when clicked on a tab. But i am not sure how.

This is what i do now:

{
                xtype: 'tabpanel',
                activeTab: 0,
                region: 'center',
                items: [
                    {
                        xtype: 'panel',
                        title: 'All',
                        items: [grid]

                    },
                    {
                        xtype: 'panel',
                        title: 'Closed'
                    },
                    {
                        xtype: 'panel',
                        title: 'Open'
                    }
                ],
                 listeners: {
            click: function () {
                alert('test');
            }
                         }
            }

How can is display All, Closed or Open when there is clicked on that tab?

like image 220
Rick Weller Avatar asked Jan 24 '12 10:01

Rick Weller


1 Answers

There is no event for tab click in TabPanel, however you can bind into click event on each tab:

Ext.createWidget('tabpanel', {
    items: [...],
    listeners: {
        render: function() {
            this.items.each(function(i){
                i.tab.on('click', function(){
                    alert(i.title);
                });
            });
        }
    }
});

Notice: this is ExtJS 4 based code.

like image 132
Krzysztof Avatar answered Nov 16 '22 23:11

Krzysztof