问题
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"]
});
});
回答1:
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
来源:https://stackoverflow.com/questions/23893698/how-to-change-position-of-node-on-button-click-using-jstree