Alkis Kalogeris
Alkis Kalogeris

Reputation: 17745

jstree get data after update

I pass some json data in jstree and then I update the tree. For example my initial data is

[
  { "id" : "demo_root_1", "text" : "Root 1", "children" : true, "type" : "root" },
  { "id" : "demo_root_2", "text" : "Root 2", "type" : "root" }
]

I update it a little (simple rename). "Root 1" becomes "UPDATED". How can I get the updated version of my data in json format like below?

[
  { "id" : "demo_root_1", "text" : "UPDATED", "children" : true, "type" : "root" },
  { "id" : "demo_root_2", "text" : "Root 2", "type" : "root" }
]

Upvotes: 0

Views: 520

Answers (1)

Tushar Sharma
Tushar Sharma

Reputation: 347

Okay..so basically if you want to refresh the tree with the updated data, then after the updation code, call the jstree callback:

$(tree).jstree('refresh');

This will refresh the tree with the new json data.

let me know in case of further issues.

Upvotes: 2

Related Questions