sokid
sokid

Reputation: 813

JsTree how to create a root node

How to create a root node using 'create' method

Root
 |___ Child1
 |___ Child2

I am using JsTree, by using 'json_data' I can able to create nodes, but I want to create all nodes dynamically using 'create' method.

Please help me....

Upvotes: 9

Views: 13672

Answers (2)

Mr. Lance E Sloan
Mr. Lance E Sloan

Reputation: 3387

As of version 3.0.0-beta10 of jsTree, to create a top-level node, the reference for the parent is "#". For example:

$("#jstree").jstree('create_node', '#', {'id' : 'myId', 'text' : 'My Text'}, 'last');

The older answer given here didn't work with that version of jsTree.

Upvotes: 11

Danil Speransky
Danil Speransky

Reputation: 30453

Maybe it is what you are looking for:

$("#tree").jstree("create", -1, false, "Name", false, true);

Upvotes: 1

Related Questions