jquery – 如何在jsTree中双击/单击打开/关闭节点

前端之家收集整理的这篇文章主要介绍了jquery – 如何在jsTree中双击/单击打开/关闭节点前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何在双击或单击节点名称时打开/关闭节点?喜欢它在这里工作 the first tree sample – 但有使用jsTree 0.9.8

>使用jsTree 1.0rc2

<html>
<head>
<title> dashboard</title>

<script type="text/javascript" src="_lib/jquery.js"></script>
<script type="text/javascript" src="jquery.jstree.js"></script>
<script type="text/javascript" src="_lib/jstreegrid.js"></script>
<script type="text/javascript">
//<![CDATA[

$(document).ready(function(){

var data = [{
       data: "basics",attr: {SOF: "<a href=\"http://www.w3schools.com\">Visit W3Schools.com!</a>"},children: [
         {data: "login",attr: {run: "run"},children: [                   
           {data: "login",attr: {}}
          ]
         },{data: "Academic Year",attr: {}},attr: {filter: "mini",SOF: "<a href=\"http://www.w3schools.com\">Visit W3Schools.com!</a>"}}
          ]

         }
        ]
      }];
$("div#jstree").jstree({
plugins: ["themes","json_data","grid","dnd"],json_data: {data: data},grid: {
        columns: [
          {width: 220,header: "Group"},{cellClass: "col2",value: "run",width: 40,header: "run"},{cellClass: "col3",value: "filter",header: "filter"},{cellClass: "col4",value: "SOF",width: 450,header: "SOF"}
                ]
            },dnd: {
drop_finish : function () {
},drag_finish : function () {
},drag_check : function (data) {
return {
after : true,before : true,inside : true
};
}
}
});
});
//]]>
</script>
</head>
<body>
<div id="jstree"></div>

</body>
</html>

解决方法

一种方法是启用类型和ui插件,并在默认类型上定义一个select_node事件处理程序,如下所示:
$(element)
        .jstree({ 
            "types" : { 
                "types" : { 
                    "default" : { 
                        "select_node" : function(e) {
                                            this.toggle_node(e);
                                            return false;
                                        } 

                    }
                } 
             },"plugins" : [ "themes","html_data","types","ui" ] });
原文链接:https://www.f2er.com/jquery/176877.html

猜你在找的jQuery相关文章