Jquery – Renaming a tree node dynamically outside of contextmenu in jstree

jqueryjstreerenametreenode

I use the code below to successfully create a new tree node in jstree outside of contextmenu. My question is how can you dynamically RENAME the text in a tree node in a similar manner outside of the contextmenu? Is there a .jstree("rename" ….) function that can be called to accomplish this? Much appreciated!

$("#RequirementsTree").jstree("create", null, "last", {"data" : "new_node_text",
                  "state" : "open",
                  "attr" :  { "id" : "new_node_id", "name" : "requirement" }, 
 });

I've tried the following:

        .bind("select_node.jstree", function(event, data) {
            ReqNode = data.rslt;

 $("#RequirementsTree").rename_node(ReqNode, "test");

That didn't work, however. Is there something I'm doing wrong?

Best Answer

This should work for you:

$("#demo1").jstree('set_text', [node , text] );
$("#demo1").jstree('rename_node', [node , text] );

JSTree Core Documentation...

how-can-i-rename-a-jstree-node

Related Topic