dhtmlxTabbar initialization issue with setOnSelectHandler

Hi All,

I want to attach an event when user clicks on a particular tab.
Here is the code that is used to initialize the tabbar without using setOnSelectHandler which works perfectly fine:
tabbar = new dhtmlXTabBar("somediv", "top"); tabbar.setImagePath("/webnms/dhtmlx/dhtmlxTabbar/codebase/imgs/"); tabbar.preventIECashing(true); tabbar.setSkinColors("white","#FFFACD"); tabbar.setStyle("glassy_blue"); tabbar.enableAutoReSize(false); tabbar.addTab("a3","Title 1", 120); tabbar.addTab("a4","Title 2", 120); tabbar.setContent("a3","div1"); tabbar.setContent("a4","div2"); tabbar.setTabActive("a3"); tabbar.setSize(540,350);

When trying to use setOnSelectHandler, the tab is not initialized properly. Below is the code with select Handler:
tabbar = new dhtmlXTabBar("somediv", "top"); tabbar.setImagePath("/webnms/dhtmlx/dhtmlxTabbar/codebase/imgs/"); tabbar.preventIECashing(true); tabbar.setSkinColors("white","#FFFACD"); tabbar.setStyle("glassy_blue"); tabbar.enableAutoReSize(false); tabbar.addTab("a3","Title 1", 120); tabbar.addTab("a4","Title 2", 120); tabbar.setContent("a3","div1"); tabbar.setContent("a4","div2"); tabbar.setTabActive("a3"); tabbar.setSize(540,350); tabbar.setOnSelectHandler(functionName);

we have the older version of dhtmlxTabbar so can’t use attachEvent for “onSelect”.

Is there anything that is missed in the initialisation when using the Handler?

Thanks in Advance!!

Hello,

could you provide the example of functionName ?

Here is the function definition:

function functionName(){
	var newTab = tabbar.getActiveTab();
	if(newTab == "a3" || newTab=="a4"){
		document.getElementById("div3").style.display = "none";
	}else{
		document.getElementById("div4").style.display = "block";
	}
}

here tabbar is defined as the global variable.

The functionName should return true. In the other case, a clicked tab whould be opened. Instead of getActiveTab() in this function you may use its first parameter:

function functionName(newTab,oldTab){ if(newTab == "a3" || newTab=="a4"){ document.getElementById("div3").style.display = "none"; }else{ document.getElementById("div4").style.display = "block"; } return true }

Thanks for the help. It solved the issue.