I'm using jstree to create a tree.
I'm trying to create a new node, but I'm not getting it.
The first node level will already be loaded in html, so only the next level will be added by js. Here is an example:
$("#tree").jstree();
$("#tree").on("click",function(){
var nodeSelecionado = jQuery("#tree").jstree("get_selected");
console.log(nodeSelecionado[0]);
jQuery("#tree").jstree('create_node', $("#"+nodeSelecionado[0]), "node novo", 'last');
jQuery("#tree").jstree("open_node", $("#"+nodeSelecionado[0]));
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.0.8/jstree.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jstree/3.0.8/themes/default/style.min.css" rel="stylesheet"/>
<div id="tree">
<ul>
<li class="jstree-closed">Node 1</li>
<li class="jstree-closed">Node 2</li>
</ul>
</div>
Thanks for the help.