I want to create jsTree (st 3.0.2) using the JSON format on "Filling the tree using JSON" given at http://www.jstree.com/docs/json/
{
id : "string"
text : "string"
icon : "string"
state : {
opened : boolean
disabled : boolean
selected : boolean
},
children : []
li_attr : {}
a_attr : {}
}
From the instance, I create my tree using:
// create the instance
$('#jstree').jstree({
"core": {
"animation": 150,
"check_callback":true,
'data': new_data //json object
},
"types": {
"#": {
"valid_children": ["folder"]
},
"folder": {
"valid_children": ["file"]
},
"file": {
"valid_children": [""]
}
},
"plugins": ["dnd", "search", "wholerow", "types"]
});
I want to make sure that the folders are not in other folders and the files are not in other files. Files go only in folders.
I want to know how to pass type information to my json object (new_data) so that the types are applied.
I managed to get a method $("#jstree").jstree("set_type", $(this), "file");, but I don't like the dirty check approach. Also, I want the type to be applied in JSON and NOT outside
, . , (. ) , / .
