programmatically add Node in jstree

Sunil Madan picture Sunil Madan · Apr 24, 2015 · Viewed 15.2k times · Source

I am trying to add a new node in jstree programmatically on button click, as well as on contextmenu create click, but there is some issue.

Here is the link of fiddle.

<div id="jstree">
  </div>
<button id="sam">create node</button>

Answer

vakata picture vakata · Apr 24, 2015

Here is your fiddle, fixed to work: http://jsfiddle.net/3q9Ma/223/

You were calling create_node with an array, which was wrong, also the string value 'null' was not the correct way to create a root node - use the special string value '#' (in later versions null works too, but not as a string).

You might consider upgrading the jstree version - your fiddle was using a very early beta. Also keep in mind jstree itself does not require Angular.