I am using ExtJS 4.1.1. I extended a class from Ext.TabPanel, and added a new method "removeAllTabs()". The belowing is my code:
MyTabPanel = Ext.extend(Ext.TabPanel, {
extend: 'Ext.tab.Panel',
removeAllTabs:function(){
this.items.each(function(item){
this.remove(item);
});
}
});
tabPanel = Ext.create('MyTabPanel', {
activeTab: 0,
autoDestroy: false,
defaults :{
autoScroll: true,
bodyPadding: 10,
closeAction: "hide",
},
items: []
});
I can add some tabs to it dynamiclly like this:
tabPanel.add(App.tab1); tabPanel.add(App.tab2);
Then I call this methmod to remove all tabs at somewhere:
tabPanel.removeAllTabs();
No error is reported, but nothing could be removed.
Then I modified the method as this:
MyTabPanel = Ext.extend(Ext.TabPanel, {
extend: 'Ext.tab.Panel',
removeAllTabs:function(panel){
panel.items.each(function(item){
panel.remove(item);
});
}
});
Then I call this methmod at somewhere:
tabPanel.removeAllTabs(tabPanel);
It can works well.
Why doesn't "this" work? How can I use "this" to achieve this purpose?
Thanks!