Alex Rivera | Logout

How do I get the id of the selected node in jsTree?

Asked 2010-04-06T14:22:28.623
24

How can I get the id of the selected node in a jsTree?

function createNewNode() {
  alert('test');
  var tree = $.tree.reference("#basic_html");
  selectedNodeId = xxxxxxxxx; //insert instruction to get id here
  tree.create({ data : "New Node Name" }, selectedNodeId);
}
Edit
Report

1 Answer

1

I was having problems getting the selected ids from a tree with MULTIPLE selections. This is the way I got them:

var checked_ids = [];
$("#your-tree-id").jstree('get_selected').each(function(){    
      checked_ids.push($(this).data('id'));                         
});
answered 2013-04-22T13:35:21.867

Your Answer