Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Jennifer on Oct 06, 2008 07:30
open dhtmlx forum
dhtmlxTabbar : onClick?

Hi, I am wondering how to set an onClick Handler. I read through the knowledge base and found something called setOnSelectHandler, but it doesn't work for what I need.

Let's say I want to call a function, tabclick, after a tab is clicked, and tabclick will alert a message. If I use setOnSelectHandler, and at the same time, I used mytabbar.setTabActive(tabId), it will continuously alert the user since the tab is "selected". But I need the alert to pop up once, after a tab is clicked.

There is something in the API events list called "onClick" but I am not sure how to use that?

Hope that makes sense!
Thanks in advance.
Answer posted by Support on Oct 06, 2008 07:55
If you are using setTabActive from onSelect event handler it will generate new call on onSelect event and as result you will get event recursion.
Just add a bit of code to resolve it.

var nativeEvent = true;
tabbar.setOnSelectHandler(function(tabId){
   if (!nativeEvent) return true;
   nativeEvent = false;

   //any code here
   mytabbar.setTabActive(tabId), //will not cause resursion anymore
  ....

   nativeEvent = true;
   return true;
});