Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jstree节点不';使用ui插件时无法工作_Javascript_Jstree - Fatal编程技术网

Javascript Jstree节点不';使用ui插件时无法工作

Javascript Jstree节点不';使用ui插件时无法工作,javascript,jstree,Javascript,Jstree,我发现使用ui插件会断开树节点的链接。这并不是什么新鲜事,我在别处找到了这个问题的参考文献。第一个原因是jquery验证插件的v1.6有问题。我没有使用那个插件,所以这不可能是原因 我还发现了一篇很好的帖子,介绍了几种将jstree clicked类添加到的方法 $(函数(){ $(“treediv”) jstree先生({ “核心”:{ “动画”:0 }, “主题”:{ “主题”:“经典” }, “插件”:[“主题”、“html_数据”、“cookies”、“ui”] }); }); 如果

我发现使用ui插件会断开树节点的链接。这并不是什么新鲜事,我在别处找到了这个问题的参考文献。第一个原因是jquery验证插件的v1.6有问题。我没有使用那个插件,所以这不可能是原因

我还发现了一篇很好的帖子,介绍了几种将jstree clicked类添加到
的方法

$(函数(){
$(“treediv”)
jstree先生({
“核心”:{
“动画”:0
},
“主题”:{
“主题”:“经典”
},
“插件”:[“主题”、“html_数据”、“cookies”、“ui”]
});
});
如果我拿出ui插件,然后点击链接,我就可以像预期的那样访问yahoo.com。有人有什么想法吗?

我想我有。我相信ui插件允许“选择”节点,但点击不会传递到锚标记。因此,每当选择一个节点时,我必须绑定一个要执行的函数。我用一个.bind完成了这项工作,如下所示:

  .bind("select_node.jstree", function (e, data) {
    var href = data.rslt.obj.children("a").attr("href");
    // this will load content into a div:
    $("#contents").load(href);
    // this will follow the link:
    document.location.href = href;
  }) 
作为一个附带的好处,这个示例还向我展示了单击一个树节点并在另一个div中显示动态内容是多么容易。例如,假设树节点定义如下(使用html_数据jstree插件和struts2):


  • 单击该树节点将执行do something操作,结果将显示在id为“contents”的div中。

    @Metro Smurf我也有同样的问题,除了by jtree是框架集的一部分。它位于LeftHandside窗格中,我希望单击该节点以将righthandside窗格替换为链接内容。但是有了这个补丁,它取代了lefthandside,即使没有jstree,html链接也能正常工作。有什么想法吗?@PaulTaylor-我不知道;我只是澄清了答案。Jeff会问的。啊,好吧@Jeff有什么想法吗?v3+上还有
    ui
    插件吗?
      .bind("select_node.jstree", function (e, data) {
        var href = data.rslt.obj.children("a").attr("href");
        // this will load content into a div:
        $("#contents").load(href);
        // this will follow the link:
        document.location.href = href;
      }) 
    
    <li id="node1">
        <a href="do-something.action">Do Something</a>
    </li>