我通过这种方式制作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","data": { "title": "1","icon": null },"state": "","children": [{ "attr": { "id": "10","mdata": null },"data": { "title": "leaf","icon": null },"children": [] }] },{ "attr": { "id": "8","data": { "title": "leaf","children": [{ "attr": { "id": "9","children": [] }] }] }]'
无论我如何收到这个字符串,当用户想看树时我已经有了这个字符串.
在这里我得到一个问题:我如何初始化jsTree并使用下面的字符串为用户显示它.
解决方法
可能你想要那样的东西?
http://jsfiddle.net/radek/fmn6g/11/
>在按钮单击时插入jsTree的位置.
>点击函数上的javascript插入’jstree’div并且还包含jsTree定义.
>如您所见,我也使用json数据类型.
更多信息,在我的问题display jsTree on click
这就是你追求的吗?