**I'm building dojo tree using the following code:
The tree is displayed as expected. The problem that I have is that the onClick event is only fired on leaf nodes. When I click on the root level node(I have several root level) it is just open showing child nodes.
How can I add "extra" onClick functionality to the root nodes?
You've got
openOnClick
set to true for your tree. I think the API docs answer this as well as I possibly could.http://dojotoolkit.org/api/dijit/Tree/openOnClick
That said, it looks like you'd be able to connect to
_onClick
instead and do whatever you want (that's the method responsible for callingonClick
only whenopenOnClick
is false, anyway). Or, if you wanted to feel a little less guilty about accessing private members,dojo.declare
yourself a subclass ofdijit.Tree
, extending_onClick
to also fire another function you define as public.