PDA

View Full Version : duplicated tabs



mrajkovic
10 Mar 2012, 10:09 PM
Hi everyone,

I have an issue with the tab panel.

I have a navigation menu down the left hand side of the screen with navigation buttons that opens tabs on the right of the screen in a tab panel..

They open and close fine, but when you click on the same button twice, instead of setting the tab as active it duplicates the tab and then the tab no longer functions till the page is reloaded.

is there anyway i can stop duplicate tabs from opening up on the screen?

Help is appricated :)
Milan.



Ext.getCmp("button_0").setHandler(function (){
tab = Ext.create('Extranet.view.Bulletin_board');

Tab_Panel.add(tab);

Tab_Panel.setActiveTab(tab);
});

Farish
11 Mar 2012, 12:38 AM
this is because you are creating and adding the tab each time the button is clicked. when the button is clicked, you should check if that tab already exists/is the active tab (depending on your design) and if so, do nothing. else create the tab and add it to the tab panel.

mrajkovic
11 Mar 2012, 1:10 AM
this is because you are creating and adding the tab each time the button is clicked. when the button is clicked, you should check if that tab already exists/is the active tab (depending on your design) and if so, do nothing. else create the tab and add it to the tab panel.

But how do you check if the tab already exists? i can't find any documentation on this anywhere...

Farish
11 Mar 2012, 2:04 AM
if you have assigned an id to the tab, you can use Ext.getCmp('tab-id'); If this returns null that means that this component does not exist.