user944513
user944513

Reputation:

How to change position of node on button click using jstree?

Can you please tell me is there any way to change the position of node on button click.actually I am using jstree in my demo.I read all API http://www.jstree.com/api/ I didn't find any way to change the position of node on button click. In my demo "b" node on second position. Can we change the position of node on button click .it ("b" node)will come on "first" and "a" node come on second.

http://jsfiddle.net/fuu94/185/

$(document).ready(function() {
    $('#tree').jstree({
        core: {
           check_callback: true
        },
        dnd: {
           check_while_dragging: false
        },
        "plugins": ["dnd"]
     });
});

Upvotes: 1

Views: 4379

Answers (1)

ezanker
ezanker

Reputation: 24738

Looking at the api, you can use move_node. It seems to require a parent mode, so for your example I have added an overall root node with id="root0". Then on button click:

$('#tree').jstree("move_node", "#b", "#root0", 0);

This says take node named "b", move it to parent named "root0" and put it at position "0".

Updated FIDDLE

Upvotes: 1

Related Questions