Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by stran on Dec 20, 2007 15:43
open dhtmlx forum
dhtmlxTabbar contents

I have a Tabbar built from an XML source, and within each tab I have several contents that contains <a></a> link to different pages; the XML data is pushed from the server via CDATA contents.

My question is when I move from TAB to TAB, it shows me the correct contents consisting of the LINKs that I populate from the XML, but the problem is the page shown underneath the TABBAR stays the same (I did NOT use iframe). I have included the same TABBAR to all of my pages and use it as a navigation.

My questions:

1) Is there a way that I when I click on the individual TAB, it would also trigger my first <a> link contained in that TAB.
2) If I use setOnSelectHandler(), it does NOT show any of my contents, why?

Thanks.

Answer posted by Support on Dec 21, 2007 02:54
>>Is there a way that I when I click on the individual TAB

You can use setOnSelectHandler in next manner

tabbar.setOnSelectHandler(function(){
    var link=tabbar._conZone.getElementsByTagName("A")[0].getAttribute("href"); //get first link on page
    document.location.href=link;
    return true;
});


>>If I use setOnSelectHandler(), it does NOT show any of my contents, why?
The result which you returns from onSelect handler affect further processing

return true - allow active tab changing
return false or not return at all - event will be blocked ( tab will not be changed )

Answer posted on Dec 21, 2007 09:43

Thanks for the quick response, BUT this will always link me to the current TAB's 1st <a> link. How can I access the NEW TAB 1st link? that would really help. 

THANKS. 

Answer posted by Support on Dec 22, 2007 01:45
>>how can I access the NEW TAB 1st link? that would really help.
You can use setOnSelectHandler in next manner

tabbar.setOnSelectHandler(function(id){
    var link=tabbar._content[id].getElementsByTagName("A")[0].getAttribute("href"); //get first link on page
    document.location.href=link;
    return true;
});

This will work for statically tabbars, in case of tabbars the same approach can be used but with setOnTabContentLoaded method, which allow to set function which will be activated after data dynamically loaded to tab.
Answer posted by stran on Dec 22, 2007 08:20
Thank you - it works great.