我希望能够同时选择文件夹节点标签以展开树,同时还调用树的onClick函数。 我已经将树的openOnClick属性设置为true,这将使树在选择节点标签时展开,但是从不调用onClick函数。
我的代码看起来像这样......
tree = new Tree({ model: treeModel, openOnClick : true, // This prevents onClick function from firing onClick: function(item, node, event){ // this function is never called because openOnClick is enabled alert("This message will never appear"); }, }, "tree");我需要openOnClick和onClick才能工作。 我正在使用dojo 1.9
有任何想法吗???
I want to be able to both select the folder node label to expand the tree while also calling the onClick function for the tree. I've set the openOnClick property of the tree equal to true which will enable the tree to expand when the node label is selected however then the onClick function is never called.
My code looks like this...
tree = new Tree({ model: treeModel, openOnClick : true, // This prevents onClick function from firing onClick: function(item, node, event){ // this function is never called because openOnClick is enabled alert("This message will never appear"); }, }, "tree");I need both openOnClick and onClick to work. I am using dojo 1.9
Any ideas???
最满意答案
在挖掘dijit / Tree.js源代码之后,我想出了解决方案。
tree = new Tree({ model: treeModel, // openOnClick : false, // Don't set openOnClick equal to true onClick: function(item, node, event){ alert("This message will NOW appear!!!"); this._onExpandoClick({node: node}); // This will expand the node }, }, "tree");Tree.js文件中的逻辑检查openOnClick值,并根据其值扩展节点或调用onClick函数。 我仍然不确定为什么这两个功能彼此独占。
有人知道为什么吗?
After digging through the dijit/Tree.js source code here was the solution I came up with.
tree = new Tree({ model: treeModel, // openOnClick : false, // Don't set openOnClick equal to true onClick: function(item, node, event){ alert("This message will NOW appear!!!"); this._onExpandoClick({node: node}); // This will expand the node }, }, "tree");The logic in the Tree.js file checks the openOnClick value and based on its value will either expand the node or call the onClick function. I'm still not sure why the two functions are exclusive from one another.
Does anyone know why this is?
更多推荐
发布评论