2

How can we add click listener to activeitem in Tabbar, As i search I found that only event available is activeitemchange so the action will perform only if i click on another item and then on myitem

veena
  • 39
  • 3

2 Answers2

1

Use the delegate property when adding listeners to add a listener directly to the tab itself:

var tabPanel = Ext.Viewport.add({
    xtype: 'tabpanel',

    items: [
        {
            title: 'one',
            html: 'one'
        },
        {
            title: 'two',
            html: 'two'
        }
    ]
});

tabPanel.on({
    delegate: 'tab',
    tap: function(tab) {
        console.log(tab.getText());
    }
});
rdougan
  • 7,217
  • 2
  • 34
  • 63
0

Simpler:

add the button normally as it would be a tab... then, in tabpanel config element, add:

listeners: {
    activeitemchange: function(source, value, oldValue, eOpts) {
        if(value.id == 'chiama') {
                            // do actions...
            // for example open a link: 
                            // document.location = 'www.google.it';

            source.setActiveItem(oldValue); //avoid tab switching
            return false; // avoid tab switching
        }
    }
}
Marco Marsala
  • 2,332
  • 5
  • 25
  • 39