JsTree Get a new node AFTER node

I am trying to get the text value of a newly created node AFTER the user edits the name of the new node and press Enter.

When I do this:

.on('create_node.jstree', function (e, data) { var id = data.node.id; alert($('#' + id).text()); }); 

All I get is the “New Node” in my post. I have been combing this site for a response, and have also been looking at the API documentation on the jstree website for some time. But they provide a few examples, since beginner jQuery is very difficult for me to understand.

So my question is, what event do I really need to program to be able to get the identifier of the created node? is this changed.jstree event? If so, how can I use this?

EDIT I can mention that I am trying this through the context menu; This is how I created my “created” element:

  items = { "create": { "label": "New Category", "action": function (obj) { $node = tree.create_node(node); tree.edit($node); } } } 
+2
source share
1 answer

The event you are possibly looking for is rename_node.jstree . It will look like this:

 .on('rename_node.jstree', function (e, data) { //data.text is the new name: alert(data.text); }); 
+4
source

Source: https://habr.com/ru/post/1432349/


All Articles