I am working with ExtJs 4.0 ( Ext Designer 1.2.0). I have a panel with card layout which contains a button(add tab btn) and a tab panel. Each tab contains a separate toolbar with button. Add tab btn would add Tab2 if it is closed.
I observed that when I run the application, event on 2nd tab's button can be executed but if I close the second tab and add it dynamically from add tab btn, event won't be executed.
Any suggestions??
Following is my code : (MyPanel.js)
Ext.define('MyApp.view.MyPanel', {
extend: 'MyApp.view.ui.MyPanel',
initComponent: function() {
var me = this;
me.callParent(arguments);
me.down('button[id=addTab]').on('click',me.onAddTabClick,me);
me.down('button[text=Second Button]').on('click',me.onSecondBtnClick,me);
},
onSecondBtnClick: function(){
alert("Second Btn");
},
onAddTabClick: function(){
var myTab = this.down('#myTabPanel').child('#tab2');
if (myTab) {
myTab.show();
} else {
this.down('#myTabPanel').add({
title : 'Tab2',
activeTab: 0,
closable : true ,
id: 'tab2',
items: [{
xtype: 'panel',
id: 'tab2',
closable: true,
title: 'Tab 2',
dockedItems: [
{
xtype: 'toolbar',
height: 29,
id: 'Tab2Toolbar',
dock: 'top',
items: [
{
xtype: 'button',
text: 'Second Button'
}
]
}
]
}]
}).show();
}
}
});