EXTJS OnClick标签事件

时间:2010-12-20 16:42:20

标签: extjs tabs

有没有办法将OnClick事件附加到EXTJS中的制表符开关?

我像这样制作网格:

var simple = new Ext.FormPanel({
    labelWidth: '100%',
    border:false,
    width: '100%',
            style: 
            {
                height: '291px'
            },
    items: {
        xtype: 'tabpanel',
        activeTab: 0,
        //labelWidth: 75, // label settings here cascade unless overridden
        items:[{
        url:'save-form.php',
        title: 'Tab 1',
  ...

谢谢!

3 个答案:

答案 0 :(得分:8)

在标签定义如下之后,我在监听器中添加了:

//define all tabs, and after the ] from the tab panel JSON: 
listeners: {
    'tabchange': function(tabPanel, tab) {
        alert("tab changed");
    }
}

这只是在标签更改时发出警报,这足以满足我的需要。我不确定如何找出当前标签的哪个标签。

希望这有助于将来。

答案 1 :(得分:2)

当有效标签发生变化时会触发tabchange事件:http://www.sencha.com/learn/Ext_FAQ_TabPanel

答案 2 :(得分:0)

There is no event for tab click in TabPanel, however you can bind into click event on each tab. You can add custom event. 
Following example help to you. 


{
  xtype : 'tabpanel',
  items : [{
    xtype : 'panel', 
    title:  'ABC'
   },{
      xtype : 'panel',
      title : 'XYZ'
}],
  listeners: {
    render: function() {
     this.items.each(function(panel){
         // Added tabclick event for tabpanel                                                                        
         panel.tab.on('click', function(){
       panel.addEvents('tabclick');  // addded event to panel 
       panel.fireEvent('tabclick', panel);
      });
       });
      }
    }
        }