TabBar: How to add a tab at specific position

Ok, I have created a tab bar with a starter tab and the last tab called “NEW”. I intend to intercept the OnSelect and when the user clicks the NEW tab, I want to use the addTab(id, text, size, position) function to add a tab just before NEW (ie, not the last but next to last tab) and then return false to cancel the selection change. I got all the OnSelect stuff working but I can’t find anywhere in the documentation how to add a tab after or before another tab and I also see no documentation on obtaining the ID of an existing tab. How do I get the position info to provide to the addTab function?

TIA
Mike Audleman

Hello
tabbar doesn’t provide method that returns number of tabs. Try to use the following approach:

tabbar.attachEvent(“onSelect”,function(id){
if(id==“add_new”){
var index = tabbar._rows[0].tabCount-1;
var uid = (new Date()).valueOf();
tabbar.addTab(uid,“Tab title”,100,index);
window.setTimeout(function(){
tabbar.setTabActive(uid);
},1);
return false;
}
return true;
})

Will the index still be correct if tabs are closed via the close button?
Here is the add sequence:
Main
NEW

Then the user clicks NEW and addds tab:
Main
Extra 1
NEW

Then another add:
Main
Extra 1
Extra 2
NEW

Then Delete:
Main
Extra 1
NEW

Then another add:
Main
Extra 1
Extra 3
NEW

Will .tabCount-1 allways point to NEW-1 even though Extra 1, Extra 2, and Extra 3 were added AFTER the NEW tab was added?

tabCount-1 points to the last tab in tabbar.

The approach provided before adds the new tab before the last tab.