dojo tree event on root nodes

2019-08-19 02:31发布

**I'm building dojo tree using the following code: enter image description here

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?

1条回答
祖国的老花朵
2楼-- · 2019-08-19 03:16

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 calling onClick only when openOnClick is false, anyway). Or, if you wanted to feel a little less guilty about accessing private members, dojo.declare yourself a subclass of dijit.Tree, extending _onClick to also fire another function you define as public.

查看更多
登录 后发表回答