如何将单击侦听器添加到tabar中的ActiveItem,当我搜索时,我发现只有可用的事件是ActiveIteMchange,因此只有在我单击另一个项目然后在Myitem上
在添加侦听器时使用delegate
属性直接将侦听器添加到选项卡本身:
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());
}
});
更简单:
正常添加按钮,因为它将是一个选项卡...然后,在TABPANEL配置元素中,添加:
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
}
}
}