11
votes

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>
1
You redacted this wrong ;) - Enrique Quero
Could you be more specific on what error(s) you are receiving? - Cullub
No any error getting, even console and alert is working fine, but the problem is new node is not getting added. - Sunil Madan
take a look at this post stackoverflow.com/questions/6871698/… I suspect that you passing null as the parent node is the issue. - bhspencer

1 Answers

13
votes

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.