I have the same requirement to create the root nodes from scratch, and name the root nodes based on a selected item from a drop-down list in the page. It works fine, without "unique" plugin and "types". When I use either "unique" plugin or "types", I wont be able to create any root nodes. Please find below the code snippet,
$("#jstree_demo").jstree({
"core" : { "animation" : 0,
"check_callback" : true },
"themes" : { "stripes" : true },
"plugins" : ["wholerow", "contextmenu", "dnd", "search", "state", "types", "unique" ] ,
"types" : {
"#" : { "max_children" : -1, "max_depth" : 4, "valid_children" : ["root"] },
"root" : { "icon" : "../css/images/sort_both.png", "valid_children" : ["default"] },
"default" : { "valid_children" : ["default","file"] },
"file" : { "icon" : "glyphicon glyphicon-file", "valid_children" : [] }
}
});
$("#create-btn").click(function(){
$("#jstree_demo").jstree("create_node", "#", $("#ruleCat").val());
});
Could you please help me to find the issue? Thank you.