【问题标题】:How to enable openOnClick for a Dojo/Dijit Tree and still call onClick function如何为 Dojo/Dijit 树启用 openOnClick 并仍然调用 onClick 函数
【发布时间】:2014-09-19 20:24:57
【问题描述】:

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

有什么想法吗???

【问题讨论】:

    标签: dojo dijit.tree


    【解决方案1】:

    在挖掘了 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 函数。我仍然不确定为什么这两个功能是相互排斥的。

    有人知道这是为什么吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-18
      • 2016-05-10
      • 1970-01-01
      相关资源
      最近更新 更多