Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by SLHK on Feb 03, 2008 22:55
open dhtmlx forum
how to pass tree object to function call?

If I have 2 dhtml Tree in a single page,how can I retrieve the tree object in javascript function call?
As I tried to get the treeObject with the following statements, the object return is not a tree object. All dhtmlTree's function call are not valid.

function isValidMove(treeObj) {
treeX = document.getElementById(treeObj.id); // treeObj is the DIV id
alert(treeObj.id + ":" + treeX.getSelectedItemId()); // treeX is not an dhtmlTree object, is just a DIV
}

How can I pass/get the dhtmlTree object in a function? especially in the case that I have 2 trees in a single page?
I do not want to hardcode the tree object with tree1, tree2, tree3, ... and so on ...

Thanks in advance.
Answer posted by Support on Feb 04, 2008 04:13
Inside any event handler you can use this as pointer to related object

mytree.attachEvent("onClick",function(id){
    alert(this.getSelectedItemId());
});

There is  no way to retrieve tree object from ID of tree container.