How can I refresh the contents of a jsTree?

前端 未结 5 1635
心在旅途
心在旅途 2020-12-29 00:55

I have loaded a jsTree with an AJAX call that returns JSON data. How can I refresh the tree so that it reloads its contents?

相关标签:
5条回答
  • 2020-12-29 01:17
    var tree = jQuery.jstree._reference("#files");
    tree.refresh();
    

    or

    var tree = jQuery.jstree._reference("#files");
    var currentNode = tree._get_node(null, false);
    var parentNode = tree._get_parent(currentNode);
    tree.refresh(parentNode);
    
    0 讨论(0)
  • 2020-12-29 01:28

    for jstree3 . I use destroy() function and again create tree running jstree() function

    0 讨论(0)
  • 2020-12-29 01:34

    $('#treeId').data('jstree', false).empty().jstree(json);

    0 讨论(0)
  • 2020-12-29 01:42

    Turns out is is as simple as calling:

       tree.jstree("refresh");
    
    0 讨论(0)
  • 2020-12-29 01:44

    At version 3 you can reload the tree :

    $('#treeId').jstree(true).settings.core.data = newData;
    $('#treeId').jstree(true).refresh();
    
    0 讨论(0)
提交回复
热议问题