Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by shadowxkimo on Sep 11, 2008 20:14
open dhtmlx forum
onXLE event problem

I'm using the dynamic loading function of dhtmlTree v1.5.
The scenario I need is that some javascript code should be executed after a tree loaded completely from XML.
I have specified the itemId of the root item, so that I could use onXLE event function to execute my code when the root item loaded.

My abstract code:

tree = new dhtmlXTreeObject(document.getElementById('contentTree'),"100%","100%","booksRoot");
dhtmlxTreeInitAttachEvent = tree.attachEvent("onXLE",dhtmlxTreeInit);
tree.setXMLAutoLoading("FullTreeHierarchyQuery.do");
tree.loadXML("FullTreeHierarchyQuery.do?id=booksRoot");

function dhtmlxTreeInit(tree,itemId)
{    
//make sure the root item(itemId=booksRoot) is loaded
    if(itemId=='booksRoot')
    {        
//my code will be executed.
}
}

I found my code will executed correctly in IE or Firefox. But in Safari or Opera, the event will be triggered when the root item start to be loaded( it means the descendant items are still not loaded).Because the content of my code is checking the descendant items, naturally, it will fail. Is it the bug of library? How should I do to execute my code correctly in these browsers?
Answer posted by Support on Sep 12, 2008 02:41

The issue can't be reconstructed locally. Which version of dhtmlxtree you are using?

The code of onXLE handler executed only after XML loaded and processed, it works for all browsers. Sample attached. 

By the way, if you need to exec code only after top level loading, you can use more simple syntax. 

tree.loadXML("FullTreeHierarchyQuery.do?id=booksRoot",function(){
             //my code will be executed.
});

Attachments (1)