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

为君一笑 提交于 2019-12-11 08:57:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!