重新加载jstree而不刷新页面
我正在尝试重新加载 jstree
而不重新加载或刷新页面,重新加载应该发生在按钮的 onclick
上,因此当单击按钮时,我调用
$("#tree-container").jstree('destroy');
//then calling the function that reads or renders the tree
它可以正常工作没有树已经渲染,但是当树已经渲染并且我单击按钮时,我得到:“无法调用未定义的方法 init。” 错误发生在 jstree 插件< /代码>。
我什至尝试删除容器,然后在调用读取树的函数之前将其重新附加到其父容器
$("#tree-container").remove();
$('#parent-tree-container').append($('<div id="tree-container"></div>'));
//then called the function that reads/renders the tree
,但这仍然不起作用。 :(
提前致谢。
I'm trying to reload a jstree
without reloading or refreshing the page, the reload should happen onclick
of a button, so when the button is clicked im calling
$("#tree-container").jstree('destroy');
//then calling the function that reads or renders the tree
that works fine when no tree is already rendered, however when a tree is already rendered and I click on the button I get this : "cannot call method init of undefined." the error occurs in the jstree plugin
.
I even tried removing the container then re-appending it to it's parent container before calling the function that reads the tree
$("#tree-container").remove();
$('#parent-tree-container').append($('<div id="tree-container"></div>'));
//then called the function that reads/renders the tree
but that still didn't work. :(
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这将进行 ajax 调用来刷新树,但不会刷新它所包含的页面:
这是最好的方法,但如果您愿意,您可以在初始 div 上重建 jstree,而无需先销毁它:
$( "#tree-container").jstree({
等This will make an ajax call to refresh the tree, but not the page it's contained in:
That is the best method, but if you prefer, you can just rebuild the jstree over the initial div without destroying it first:
$("#tree-container").jstree({
etc你使用的是 jQuery 1.6.2 吗?如果是这样,请尝试较低的版本 - 1.6.1 应该可以。 - 参见此处
Are you using jQuery 1.6.2? If so, try a lower version - 1.6.1 should work. - see here