jsTree open_all 不一直触发
我通过一个 AJAX 调用从服务器获取 x 个项目及其相关的目录结构,然后它与服务器断开连接。现在所有操作都应该通过浏览器进行。
现在,列表框和 jsTree 中加载的项目应该加载其关联的数据 onChange 事件。一切工作正常,但 jsTree 的 open_all 仅适用于第一次列表框单击。之后就崩溃了。
这是我的代码。
function Refresh(item) {
$('#MainTree').bind("loaded.jstree", function (e, data) {
$('#MainTree').jstree("open_all"); //WORKS FINE
//data.inst.open_all(-1); //WORKS FINE
}).jstree({
"json_data": {
"data": [item]
},
"themes": {
"theme": "default",
"dots": true,
"icons": true
},
"ui": {
"select_limit": 1
},
"plugins": ["themes", "json_data", "ui", "types"]
});
}
下面是我的 HTML 按钮代码,用于折叠和折叠打开也可以正常工作。有什么想法吗?
<input type="button" value="Collapse All" onclick="$('#MainTree').jstree('close_all');">
<input type="button" value="Expand All" onclick="$('#MainTree').jstree('open_all');">
I get x number of projects and their related directory structure from the server in one AJAX call, then it disconnects from the server. Now all operation should work from the browser.
Now the projects loaded in a Listbox and jsTree should load its associated data onChange event. Everything works fine, but jsTree's open_all works only for the first Listbox click. After that it collapse.
This is my code.
function Refresh(item) {
$('#MainTree').bind("loaded.jstree", function (e, data) {
$('#MainTree').jstree("open_all"); //WORKS FINE
//data.inst.open_all(-1); //WORKS FINE
}).jstree({
"json_data": {
"data": [item]
},
"themes": {
"theme": "default",
"dots": true,
"icons": true
},
"ui": {
"select_limit": 1
},
"plugins": ["themes", "json_data", "ui", "types"]
});
}
And below is my HTML button code, for collapse & open which also works fine. Any idea?
<input type="button" value="Collapse All" onclick="$('#MainTree').jstree('close_all');">
<input type="button" value="Expand All" onclick="$('#MainTree').jstree('open_all');">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过几天的尝试,我放弃了这个并尝试了 TreeTable 插件,它运行完美。
希望这对某人有帮助。
After few days of try, I gave up this one and tried TreeTable plugin and it worked perfect.
Hope this helps someone.