Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Rodrigo Mompo on Jun 27, 2009 09:24
open dhtmlx forum
dhtmlTree - attached event onNodeSelect wont work!

Hi!, im triying to use dhmtlTree for browsing documents etc etc etc ..

so part of my code is:

function test (x) {
alert("hi there!");
}

var dhxTree = dhxLayout.cells("a").attachTree("nROOT");
dhxTree.setImagePath("/dhtmlx/dhtmlxTree/codebase/imgs/");
dhxTree.attachEvent("onNodeSelect",test);
dhxTree.insertNewChild("nROOT","nREP","<b>Repository</b>","","","","","","0");

but nothing really happens when i click on a node, i also try to attach the event "onSelect" but the same thing.

in fact i need to define a actionHandler for eah node, so i took a peek on documentation and it shows that insertNewChild 4th paramter is exactly for that, but if a put "test" there i got this error:

obj.actionHandler is not a function, i've triyed putting the "test" function after / berfore the Tree.. and also in another <script> area, but is keeps the same

thanks in adavance
Answer posted by Support on Jun 29, 2009 07:57
Instead of 
     dhxTree.attachEvent("onNodeSelect",test);
You need to use
     dhxTree.attachEvent("onClick",test);

Full list of supported events, can be checked at
               http://dhtmlx.com/docs/products/dhtmlxTree/doc/events.html#api_ev

>>in fact i need to define a actionHandler for eah node
By using attachEvent@onClick you will assign common event handler , which will be used for all items in tree by default.