View Full Version : Catching tab "close" event

30 Apr 2007, 1:09 PM

I'm trying to catch the "close" event for a tab and I'm wondering what is the appropriate way to locate the tab (because the TabPanelItem is being auto-created via the layoutManager.add()).

Currently I have something like this:

// 1) Create a panel and add it to my layout manager
var myPanel = new Ext.ContentPanel(mydiv, {...});
layoutManager.add('center', myPanel);

// 2) Wire up an event to closing that particular tab that was created
var myTab = layoutManager.getRegion('center').tabs.getTab(myPanel.getEl().id);
myTab.on("close", myCloseFunc);

I'm pretty sure that the way I'm getting that tab (myTab) is wrong. For starters, I'm not sure that the "tabs" collection is public.

I'm sure, as always, that there's something very obvious that I'm missing here :)

Thanks in advance -


1 May 2007, 12:20 AM
there is no tab close event. The event needs to be triggered on the region when a panel is removed

var region = layoutManager.getRegion('center')
region.on("panelremove", myCloseFunc)

MyCloseFunc will receive details of the panel that is removed

If you need to trap or stop a panel being removed there is a beforeremove event too.
See LayoutRegion for more info

1 May 2007, 4:27 AM
Ok, that may also work, but the code I posted definitely was working -- i.e. there is definitely a "close" event fired from the TabPanelItem when it is closed -- fired from the TabPanel.removeTab() method. Perhaps that's simply not a "public" event?

1 May 2007, 5:47 AM
Thanks -- the "panelremoved" event worked great!