如何为Dojo / Dijit树启用openOnClick并仍然调用onClick函数(How to enable openOnClick for a Dojo/Dijit Tree and stil

编程入门 行业动态 更新时间:2024-10-18 01:42:39
何为Dojo / Dijit树启用openOnClick并仍然调用onClick函数(How to enable openOnClick for a Dojo/Dijit Tree and still call onClick function)

我希望能够同时选择文件夹节点标签以展开树,同时还调用树的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?

更多推荐

本文发布于:2023-08-01 14:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1359232.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:何为   函数   openOnClick   Dijit   onClick

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!