Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Andrew on Apr 24, 2008 13:25
open dhtmlx forum
getActiveTab not working after loadXML

Here is my XML:
<?xml version="1.0"?>
<tabbar hrefmode="ajax-html">
    <row>
        <tab id="Screen" width='*' href="admin/ManagementNew.jsp?pageType=screenManager">Screen Manager</tab>
        <tab id="Profile" width='*' href="admin/ManagementNew.jsp?pageType=profileManager" selected="1">Profile Manager</tab>
        <tab id="User" width='*' href="admin/ManagementNew.jsp?pageType=userManager">User Manager</tab>
        <tab id="NavBar" width='*' href="admin/ManagementNew.jsp?pageType=navBarManager">NavBar Manager</tab>
        <tab id="VBA" width='*' href="admin/OmniMgrAdminVbaNew.jsp">VBA Manager</tab>
    </row>
</tabbar>

Here is my JavaScript:
    var tabbar=new dhtmlXTabBar("a_tabbar","top");
    tabbar.setImagePath("<c:out value='${pageContext.request.contextPath}'/>/dhtmlx/dhtmlxTabbar/codebase/imgs/");
        
    tabbar.setOnSelectHandler(tabChanged);
    tabbar.setOnTabContentLoaded(tabChanged);
    tabbar.loadXML("<c:out value='${pageContext.request.contextPath}'/>/layouts/management.xml");
        
    tabbar.setCustomStyle("Screen","#F0F8FF","#f2f0e6","tabStyleScreen");
tabbar.setCustomStyle("Profile","#F0F8FF","#f2f0e6","tabStyleProfile");
tabbar.setCustomStyle("User","#F0F8FF","#f2f0e6","tabStyleUser");
tabbar.setCustomStyle("NavBar","#F0F8FF","#f2f0e6","tabStyleNavBar");
tabbar.setCustomStyle("VBA","#F0F8FF","#f2f0e6","tabStyleVBA");

setCurrentGrid(tabbar.getActiveTab()); // <- getActiveTab returns null;
        
Answer posted by Support on Apr 25, 2008 03:31
The loading is async, so in moment when js command called the tab is not available yet.
The correct code will be

    tabbar.loadXML("<c:out value='${pageContext.request.contextPath}'/>/layouts/management.xml",function(){
        setCurrentGrid(tabbar.getActiveTab()); // <- getActiveTab returns null;
    });