javascript - JSTree, Add child node is not working -


i using jstree first time, trying add child node existing node not working far. know topic have been discussed many times tried lot of suggestions , still doesn't work out.

here piece of code

$('#jstree_div').jstree();  var elemselected=$("#jstree_div").jstree(true).get_selected(true);  var position = 'inside';  var childnode = { state: "open", data: "child node" };    $('#jstree_div').jstree("create_node", elemselected, position, newnode, false, false);
<div id='jstree_div'>    <ul>       <li id='racine' data-jstree={'opened':true,'selected':true}>         <a id='j2_6_anchor' class='jstree-clicked' href='#'></a>       </li>    </ul>  </div>

i don't know missing, greatfull if can me problem

var tree = $('#jstree_div').jstree({core:{  check_callback : true }}); 

you need add "check_callback : true" able create new node

check function parameters on theirs documentation --> https://www.jstree.com/api/#/?f=create_node([par, node, pos, callback, is_loaded])

var tree = $('#jstree_div').jstree({core:{   check_callback : true  }});    var elemselected=$("#jstree_div").jstree(true).get_selected(true);  var position = 'inside';  var childnode = { state: "open", data: "child node" ,text:"child node" };    $('#jstree_div').jstree("create_node",null, childnode);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>  <script src="https://cdn.jsdelivr.net/jquery.jstree/3.3.1/jstree.js"></script>  <div id='jstree_div'>    <ul>       <li id='racine' data-jstree={'opened':true,'selected':true}>         <a id='j2_6_anchor' class='jstree-clicked' href='#'></a>       </li>    </ul>  </div>


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -