Dhtmlxtree: onClick event triggers twice


I am currently evaluating the free version of the tree control downloaded from your website, in order to decide whether we can use the commercial version.

I am attaching an event handler for all my tree nodes using:

mytree = new dhtmlXTreeObject(target, “100%”, “100%”, 0);



Using an alert call like so:

function doOnClickTree(id)


alert(“onclick triggerred”);


will show that this event triggers twice.

Can you explain why this is happening?


The problem can’t be reconstructed with local samples.
Please be sure that tree.setOnClickHandler command executed only once ( each time when such command executed, it adds new one event handler, without removing previous one, so if it was executed twice - it will cause double call of related function )

If problem still occurs for you - please provide any kind of sample where problem can be reconstructed ( you can send it directly to support@dhtmlx.com )

I was rebuilding the tree dynamically, but I forgot to call “detachEvent” before reattaching…
The answer is that one should do:
and only after that: