parameters of jstree create_node

Artur Keyan picture Artur Keyan · Jul 29, 2011 · Viewed 30.3k times · Source

Could you please give me the list of parameters of this function and an example of usage

$('#treepanel').jstree("create_node");

Answer

olafure picture olafure · May 16, 2012

IMHO jsTree is powerful, but documentation could be improved.

The create_node function is documented here.

Be careful not interpreting the [] as a literal. They are just to indicate that the parameters are optional.

This works for jsTree version "pre 1.0 fixed":

var position = 'inside';
var parent = $('#your-tree').jstree('get_selected');
var newNode = { state: "open", data: "New nooooode!" };
$('#your-tree').jstree(
    "create_node", parent, position, newNode, false, false);

JSTree 3.3.5

From their docs "create_node" functionality has inverted args 'newNode' and 'position'

 $('#your-tree').jstree("create_node", parent, newNode, position, false, false);

https://www.jstree.com/api/#/?f=create_node([par,%20node,%20pos,%20callback,%20is_loaded])