如何重新绘制树(jtree)

How to redraw tree (jstree)

本文关键字:jtree 何重新 绘制      更新时间:2023-09-26

我使用jQuery库(jtree)来绘制树。它第一次绘制树-当页面加载时。但是当我按下按钮更新树数据时,它失败了,div变成空白。下面是刷新数据的代码:

$('#jsstree').html("");
   jQuery("jsstree").jstree("destroy");
    $('#jsstree').jstree({
        'core': {
            'data': [
               { "id": "ajson1", "parent": "#", "text": "Simple root node" },
               { "id": "ajson2", "parent": "#", "text": "Root node 2" },
               { "id": "ajson3", "parent": "ajson2", "text": "Child 1" },
               { "id": "ajson4", "parent": "ajson2", "text": "Child 2" },
            ]
        }
    });

这样做:

tree.jstree("refresh");