0

我正在使用带有上下文菜单选项的 jquery-dynatree。

对于上下文菜单上的菜单项之一,我需要将整个子树显示为一个选择。即选定的节点及其所有子节点,我可以使用以下代码来做到这一点:

node.visit(function(childnode){
    $(childnode.span).addClass("copy");  // <== This works
});

现在我有两个问题:

1)第一个问题是我有惰性节点选项,所以每当我点击菜单项时,我需要将整个子树显示为选中状态,因为我正在使用下面的代码

node.visit(function(childnode){
    childnode.expand(true);  // <== This works
    $(childnode.span).addClass("copy"); // <== Does not work
});

但它不能完全工作,它只会将节点扩展至我已初始化的级别,并且在扩展后它不会将所需的 CSS 类“复制”添加到自身或子节点。

2)第二个问题是,一旦我手动展开所有节点并选择父节点,以便使用类“复制”显示整个子树,现在每当我单击任何父惰性节点以检索这些子节点时,“复制”类从那些选定的节点中删除

期待一些解决这个问题的技巧。

4

1 回答 1

0

I have got the solution now for 1st point, as I was trying to click on parent in collapsed mode, I had to first expand the node itself before expanding its children nodes.

 node.expand(true); // This line was missing, it made the things work
                node.visit(function(childnode){
                    childnode.expand(true);
                    $(childnode.span).addClass("copy");
                });
于 2013-04-30T05:25:51.820 回答