var tabIndex = 'shouye';
var tabIndex2 = 'shouye ';
var tabIndex3 = 'shouye';
var tabIndex4 = 'shouye';
var tabIndex5 = 'shouye';
var tabIndex6 = 'shouye';
var tabIndex7 = 'shouye ';
/**
* Add a window to the TabPanel component or activate an existing window
* and load the specified resources into the window
* @param node: the incoming Node node
*/
var loadPanel = function(node) {
var id= node.id;//Get the id of the node
tabIndex7 = id;
var href = node.attributes.href; //Get the href attribute in the node
var text = node.text;
var mainPanel = Ext.getCmp('mainPanel');
//mainPanel.remove ('mainPanel', true);
var qtip = node.attributes.qtip;
var tab = mainPanel.getComponent(String(id));//Get the component object with the specified id
if(tab ) {
mainPanel.setActiveTab(tab);//Check whether the current Tab exists. If it exists, just activate it
return;
}
//If the tab does not exist, the following is Create tab code
tab = mainPanel.add(new Ext.Panel ({
//Configuration to create a new tab
id: String(id),//Set ID, need to be forced to string Type
title: text,//Set tab title
tabTip: text,
html: '',
autoScroll: true,
enableTabScroll:true,
defaults: {autoScroll:true},
closable : true //Whether it can be closed
} ));
mainPanel.setActiveTab(tab);//After creating a tab, activate it
mainPanel.remove(tabIndex, true);
tabIndex = tabIndex2;
tabIndex2 = tabIndex3;
tabIndex3 = tabIndex4;
tabIndex4 = tabIndex5;
tabIndex5 = tabIndex6;
tabIndex6 = tabIndex7;
}
Use a variable to store id to load new Swap IDs when selecting tabs, thereby limiting the number of open tabs. If you don't absolutely need this effect, it is recommended not to close and create tabpanels frequently.