开发者

How can I refresh the contents of a jsTree?

开发者 https://www.devze.com 2023-01-15 07:44 出处:网络
I have loaded a jsTree with an AJAX call that returns JSON d开发者_开发问答ata. How can I refresh the tree so that it reloads its contents?Turns out is is as simple as calling:

I have loaded a jsTree with an AJAX call that returns JSON d开发者_开发问答ata. How can I refresh the tree so that it reloads its contents?


Turns out is is as simple as calling:

   tree.jstree("refresh");


At version 3 you can reload the tree :

$('#treeId').jstree(true).settings.core.data = newData;
$('#treeId').jstree(true).refresh();


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);


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消