单击EXTJS中的选项卡面板的监听器

Ric*_*ler 5 tabs extjs listener

我在extjs中使用选项卡面板.我想在单击选项卡时显示警告.但我不确定如何.

这就是我现在所做的:

{
                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');
            }
                         }
            }
Run Code Online (Sandbox Code Playgroud)

单击该选项卡时,如何显示全部,关闭或打开?

Krz*_*tof 14

选项卡单击没有任何事件TabPanel,但您可以绑定到每个选项卡上的单击事件:

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

注意:这是基于ExtJS 4的代码.