Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jstree dynamically adding child node to child node not creating [closed]

Ian newbie to jquery, iam working with jstree. I am able to create tree with first of values but iam able to create childnodes to the childs present in the same tree.

i could do this

  • myttree

       mytreeval1
       mytreeval2
       mytreeval2
    

but i couldnot do this through code

  • myttree

       mytreeval1
          subtreeval
          subtreeval
       mytreeval2
       mytreeval2
    

i tried the following code.

$('#jstreedemo').jstree('create_node', 1, 'inside', 'mytreeval1', node_callback(), true); function node_callback(){alert("Iam here");}

creating tree and adding nodes are in different functions();

How to acheive this? anyone help me out with this.

like image 350
shanthi_karthika Avatar asked Jan 31 '14 07:01

shanthi_karthika


1 Answers

this has worked for me

  var position = 'inside';
  var parent = $('#jstreedemo').jstree('get_selected');
  var newNode = { state: "open", data: {'mydata'} };

  $('#jstreedemo').jstree("create_node", parent, position, newNode, false, false);
like image 75
shanthi_karthika Avatar answered Sep 24 '22 00:09

shanthi_karthika