PDA

View Full Version : Create tabs separately before creating tab panel



deving
15 May 2013, 8:30 AM
I need to have a specific tab active by default depending on the url. I was going to create the tab panel and then set the active tab, but this shows the first tab as active and then switches to the tab that I set. Instead, I want to set the tab before any tabs are shown so that you don't get that flicker between tabs.

So what I did was I tried to create the array of tabs first and checked to see which tab index should be active...then I create the tab panel and set the activeTabIndex to the index I have determined should be active by the url. The items in the tabpanel config are then set to my array of tabs that I have created.

This does not seem to be working. The correct tab is active, but all of the tabs are essentially blank...none of them have their content (although some content can be seen in weird areas on the page). What am I missing? Is creating the tabs separately outside of the panel something that can be done? Thank you!

evant
15 May 2013, 7:06 PM
There's no reason you can't do it. Since you didn't post any code it's difficult to say where you're going wrong:



Ext.require('*');

Ext.onReady(function() {

var items = [],
i = 1;

for (; i <= 5; ++i) {
items.push({
html: i,
title: 'Tab ' + i
});
}

// Calculated
var active = 2;

new Ext.tab.Panel({
renderTo: document.body,
width: 200,
height: 200,
items: items,
activeTab: active
});

});