View Full Version : Activating Tabs

1 Nov 2006, 8:45 AM
So, I've got a set of tabs I add, but, when I'm done, I'd love to reset the user to the first tab.

Been digging about, haven't found a solution yet ...

Any quick pointers ?

1 Nov 2006, 10:44 AM
Try calling setActivePanel(yourPanel) on the region. I haven't got it to work yet either. Not sure if it's my code or a bug in the beta code. If you get it to work, please let me know how you did it.

1 Nov 2006, 2:28 PM
This works for me:


1 Nov 2006, 2:53 PM
showPanel() works for me too. It handles the panel whether or not there are tabs involved.
Maybe setActivePanel is meant to be private??

1 Nov 2006, 10:09 PM
Yep, setActivePanel is considered private. Don't worry, before the official release I will document all this stuff. :)

2 Nov 2006, 1:15 AM
Hmmm ... showPanel() isn't working for me ... I'll dig around a bit and see if I can figure it out ... but at least I got pointed in *some* direction. ;)


2 Nov 2006, 7:54 AM
i use functon like that coz i create tabs and not panels:

toggleActivateTab: function(id){
tabs.active = tabs.getTab(id);

2 Nov 2006, 8:12 AM
So, to be completely specific about this ...

I have the following in my layout.

var Interface = {
hideOnLayout: true,
createTab : function(title, link, closable ){
var iframe = YAHOO.ext.DomHelper.append(document.body, {tag: 'iframe', frameBorder: 0, src: link});
layout.add('center', new YAHOO.ext.ContentPanel(iframe, {title: title, fitToFrame:true, closable:closable}));
init : function() {
layout = new YAHOO.ext.BorderLayout( document.body, {
hideOnLayout: true,
// ... region layouts ...


// ... a bunch of stuff for my north, south, east, & west regions ...

this.createTab( "Welcome", "./welcome.html", false );
this.createTab( "Search", "./search.html", false );

// at this point the search tab is highlighted, lets go back to the Welcome Tab
// FIXME <--- The showPanel call doesn't work.
layout.getRegion( 'center' ).showPanel( "Welcome" );

// ... more stuff, setting up tool tips, etc. ...


YAHOO.ext.EventManager.onDocumentReady( Interface.init, Interface, true );

... So, that's what I'm trying to do ... just not working yet ... I have seen his stuff for TabPanels & such, but since, I'm only getting the tabs as a bi-product of assigning multiple content sections to my 'center' layout region, I wanted to make sure that people trying to help knew exactly how and what I'm doing.

I know it's possible, just gotta find the right incantation.


2 Nov 2006, 8:20 AM
I think you have the same issue as described in the next thread down:

Basically, the panel methods take a panel ref or panel id, not panel title, as an arg. So you 1st need to get a ref to the panel/tab so you can pass that rather than 'Welcome'

2 Nov 2006, 1:17 PM
Thanks exactly right. You will need a reference to the panel or know the panel's element id.

2 Nov 2006, 6:57 PM
I'm trying that code ( as far as the getRegion().getPanel() calls and then using that ... and still no dice.

the exact code is

var r = this.layout.getRegion( 'center' );
var p = r.getPanel( 'Welcome' );
r.showPanel( p );

r does become the region appropriately, but, the javascript error I'm currently getting is that p has no properties... when I step through in the debugger, the getPanel call doesn't return anything for me.

Any more ideas ???

Thank you for your time & determination.


2 Nov 2006, 7:24 PM
See above, you will need a reference to the panel or the panel element's id (the iframe's id). The title will not work.

2 Nov 2006, 7:39 PM
... that works ... thank you. code is a bit ugly ( with all the temps and such ) ... but, at least it works ... thank you.