View Full Version : BeforeActivate event on tabPanelItem
manugoel2003
21 Feb 2007, 4:11 AM
does anyone know if there is anything similar to BeforeActivate event in TabPanelItem???.... I want to conditionally allow a tab to be activated or not, or maybe perform some operations before activating the tab.... it seems I have seen it somewhere but I am not able to recall or find it.... I am using yui-ext 0.40 (alpha)
thanx
tryanDLS
21 Feb 2007, 8:26 AM
The activate item fires beforeTabChange(e) before actually making that the active tab. If you set e.cancel = true, then activate will not activate the tab
manugoel2003
21 Feb 2007, 9:48 AM
thanx Tim... but what if I want to perform separate activities on "Activate" and "BeforeActivate".... just like we have "beforehide" and "hide" events in BasicDialog.....
tryanDLS
21 Feb 2007, 12:12 PM
I think handlers for beforeTabChange and tabChange would accomplish that, wouldn't they? If not, can you describe what you're trying to do?
manugoel2003
21 Feb 2007, 9:19 PM
Ya I guess that would do... I didnt think of that, thanx.... actually what I want to do is - I have a center region and an east region..... I have 3 tabs in east.... I have a certain form in center and it has a select box.... depending on the value of the select box I have to either display a message in the 2nd tab, or display a grid.... now I want to perform this validation before user tries to activate this tab, because in certain situations I might even block access to that tab and display an alert.... however I want to load the grid after activating the tab.... I guess tabChange and beforeTabChange should work
manugoel2003
22 Feb 2007, 11:07 PM
that did it.... I attached a handler to beforeTabChange and put a switch...case there for sifting through the IDs of the tabs and performing appropriate actions.... thanx tryan... here is my sample code just in case it might be useful for someone else....
This is how I attach the handler
layout.getRegion("east").getTabs().on("beforetabchange", this.onTabChange.createDelegate(this));
This is the handler
onTabChange : function(panel, e, tab){
switch (tab.id)
{
case "clientHistory":
if(getEl("customerId").dom.value == '')
{
alert('Select Client first.');
e.cancel = true;
}
else{
layout.getRegion("east").titleTextEl.innerHTML = "Client History";
this.drawClientHistoryGrid();
}
break;
case "clientProfile":
if(getEl("customerId").dom.value == '')
{
alert('Select Client first.');
e.cancel = true;
}
else{
layout.getRegion("east").titleTextEl.innerHTML = "Client Profile";
this.drawClientProfileGrid();
}
break;
case "answerBook":
break;
}
}
One more tiny thing Tim, slightly stupid though.... but what is the difference between handler and listener??... I have been wondering for some time over this
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.