【发布时间】:2011-10-31 10:15:49
【问题描述】:
我是这样制作jsTree的:
$("#myTree").jstree({
"plugins": ["themes", "json_data", "ui", "crrm", "dnd"],
"themes": {
"theme": "default",
"dots": false,
"icons": false,
"url": "../../Content/jsTreeThemes/default/style.css"
},
"json_data": {
"data" : []
}
});
并且用户看到带有空 jsTree 的页面。当用户进行某些操作时,我必须初始化我的 jsTree。但我不能使用 ajax 初始化(我不能在“json_data”中使用“ajax”)。我必须只使用这样的字符串来初始化我的 jsTree:
var stringJSON = [{
"attr": {
"id": "1",
"rel": "root",
"mdata": null
},
"data": "title": "root_jsTree",
"icon": null
}, "state": "open",
"children": [{
"attr": {
"id": "7",
"rel": "folder",
"mdata": null
},
"data": {
"title": "1",
"icon": null
},
"state": "",
"children": [{
"attr": {
"id": "10",
"rel": "folder",
"mdata": null
},
"data": {
"title": "leaf",
"icon": null
},
"state": "",
"children": []
}]
}, {
"attr": {
"id": "8",
"rel": "folder",
"mdata": null
},
"data": {
"title": "leaf",
"icon": null
},
"state": "",
"children": [{
"attr": {
"id": "9",
"rel": "folder",
"mdata": null
},
"data": {
"title": "leaf",
"icon": null
},
"state": "",
"children": []
}]
}]
}]'
无论我如何收到这个字符串,当用户想要查看树时,我已经有了这个字符串。 在这里我得到一个问题:如何初始化 jsTree 并仅使用下面的字符串为用户显示它。
【问题讨论】: