I make jsTree by this way:
$("#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" : []
}
});
And user sees page with empty jsTree. I must initialize my jsTree when user make some action. But I musn’t use ajax initialization (I musn’t use “ajax” in “json_data”). I must initialize my jsTree using only string like this:
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": []
}]
}]
}]'
No matter how I receive this string, when user wants see tree I’ve already had this string.
And here I get question: How can I initialize jsTree and display it for user using only string below.
Probably you want something like that? http://jsfiddle.net/radek/fmn6g/11/
More info in my question display jsTree on click
Is that what you are after?