jQuery 如何刷新 jsTree 的内容?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3682045/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I refresh the contents of a jsTree?
提问by GiddyUpHorsey
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?
我加载了一个带有 AJAX 调用的 jsTree,该调用返回 JSON 数据。如何刷新树以重新加载其内容?
回答by GiddyUpHorsey
Turns out is is as simple as calling:
结果就像调用一样简单:
tree.jstree("refresh");
回答by aecavac
At version 3 you can reload the tree :
在版本 3 中,您可以重新加载树:
$('#treeId').jstree(true).settings.core.data = newData;
$('#treeId').jstree(true).refresh();
回答by Aigiz
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);
回答by bydan
for jstree3 . I use destroy() function and again create tree running jstree() function
对于 jstree3 。我使用 destroy() 函数并再次创建运行 jstree() 函数的树
回答by Kedron
$('#treeId').data('jstree', false).empty().jstree(json);
$('#treeId').data('jstree', false).empty().jstree(json);