jstree复选框在使用时会挂起,除了第一级层次结构

时间:2018-09-28 09:17:42

标签: jquery ajax jstree

我正在将jstreePython http服务器一起使用来创建文件浏览器。通过AJAX延迟加载,我能够成功生成树。

启用复选框插件后,如果用户检查具有子级的第二级节点,则GUI将挂起。

Working fine Failure case. Hanged

browser.html

<script src="modules/semantic-ui/jquery.min.js"></script>
<link rel="stylesheet" href="modules/jstree/jstree.style.min.css" />
<script src="modules/jstree/jstree.min.js"></script>

<div id="container"></div>

<script>
    //mynode = null;

    $(function() {
        $('#container').jstree({
            "checkbox" : {
                "keep_selected_style" : false,
                 "whole_node": false,
                 "tie_selection" : false 
            },
            'plugins' : ['checkbox'],
            'core': {
                "check_callback" : true,
                "themes": {
                    "variant": "small"
                },
                'data': {
                    "url": "/nodes",
                    "data": function(node) {
                        //mynode = node
                        //console.log(node)
                        return {
                            "dirPath": node.data,
                            "id": node.id
                        };
                    }
                }
            }
        });

    });
</script>

根文件夹的AJAX响应为

{
  "text": "rootFolder",
  "id": 0,
  "children": [
    {
      "text": "PACKAGES",
      "data": "rootFolder/PACKAGES",
      "id": 1,
      "children": true
    },
    {
      "text": "ULKS",
      "data": "rootFolder/ULKS",
      "id": 2,
      "children": true
    },
    {
      "text": "ATS",
      "data": "rootFolder/ATS",
      "id": 3,
      "children": true
    },
    {
      "text": ".hg",
      "data": "rootFolder/.hg",
      "id": 4,
      "children": true
    },
    {
      "text": "env",
      "data": "rootFolder/env",
      "id": 5,
      "children": true
    },
    {
      "text": ".hgtags",
      "data": "rootFolder/.hgtags",
      "id": 6,
      "icon": "jstree-file"
    },
    {
      "text": ".AI.profile",
      "data": "rootFolder/.AI.profile",
      "id": 7,
      "icon": "jstree-file"
    },
    {
      "text": "HLKS",
      "data": "rootFolder/HLKS",
      "id": 8,
      "children": true
    },
    {
      "text": "SW_DESCRIPTION",
      "data": "rootFolder/SW_DESCRIPTION",
      "id": 9,
      "children": true
    },
    {
      "text": ".pydevproject",
      "data": "rootFolder/.pydevproject",
      "id": 10,
      "icon": "jstree-file"
    },
    {
      "text": "TOOLS",
      "data": "rootFolder/TOOLS",
      "id": 11,
      "children": true
    },
    {
      "text": ".project",
      "data": "rootFolder/.project",
      "id": 12,
      "icon": "jstree-file"
    },
    {
      "text": "DOCKER",
      "data": "rootFolder/DOCKER",
      "id": 13,
      "children": true
    },
    {
      "text": "LIBS",
      "data": "rootFolder/LIBS",
      "id": 14,
      "children": true
    },
    {
      "text": ".pullme",
      "data": "rootFolder/.pullme",
      "id": 15,
      "icon": "jstree-file"
    },
    {
      "text": "SETUPS",
      "data": "rootFolder/SETUPS",
      "id": 16,
      "children": true
    },
    {
      "text": ".reviewme",
      "data": "rootFolder/.reviewme",
      "id": 17,
      "icon": "jstree-file"
    },
    {
      "text": ".hgignore",
      "data": "rootFolder/.hgignore",
      "id": 18,
      "icon": "jstree-file"
    }
  ]
}

PACKAGES文件夹的AJAX响应(即当用户展开PACKAGES文件夹时)

{
  "text": "PACKAGES",
  "id": "1",
  "children": [
    {
      "text": "libexec",
      "data": "rootFolder/PACKAGES/libexec",
      "id": 20,
      "children": true
    },
    {
      "text": "share",
      "data": "rootFolder/PACKAGES/share",
      "id": 21,
      "children": true
    },
    {
      "text": "etc",
      "data": "rootFolder/PACKAGES/etc",
      "id": 22,
      "children": true
    },
    {
      "text": "lib_for_64bit_compat",
      "data": "rootFolder/PACKAGES/lib_for_64bit_compat",
      "id": 23,
      "children": true
    },
    {
      "text": "include",
      "data": "rootFolder/PACKAGES/include",
      "id": 24,
      "children": true
    },
    {
      "text": "bin",
      "data": "rootFolder/PACKAGES/bin",
      "id": 25,
      "children": true
    },
    {
      "text": "lib",
      "data": "rootFolder/PACKAGES/lib",
      "id": 26,
      "children": true
    }
  ]
}

在检查层次的第一级时未观察到问题。 checkbox working with 1st level

为什么在层次结构的第二级(和更多级)上单击时会挂起?

0 个答案:

没有答案