简体   繁体   English

在jstree jQuery插件中创建后编辑节点

[英]edit node after creation in jstree jquery plugin

I have a button that by click it, a new node was created for current selected node. 我有一个按钮,通过单击它,为当前选定的节点创建了一个新节点。

in addition I want this newly node get edit state to faster edit capability. 另外,我希望这个新节点获得编辑状态以提高编辑能力。

this is code that I wrote : 这是我写的代码:

    $('#add-node').click(function () {
    currentNode     =   $treeview.jstree("get_selected");
    $treeview.jstree('create_node', currentNode, {text : "salam"}, 'last' , function(new_node){
        $treeview.jstree("open_node", currentNode);
        setTimeout(function () {
            $treeview.jstree('rename_node', new_node);
        }, 0);
    });
});

But this doesn't work , node creates but could not rename it immediately. 但这不起作用,节点创建但无法立即重命名。

I found the solution: 我找到了解决方案:

    $('#add-node').click(function () {
    currentNode     =   $treeview.jstree("get_selected");
    $treeview.jstree('create_node', currentNode, {text : "new Node"}, 'last' , function(new_node){
        $treeview.jstree("open_node", currentNode);
        var inst = $.jstree.reference(new_node);
        inst.edit(new_node);
    });
});

just sould get a reference to newly created node then edit it . 刚刚获得了对新创建的节点的引用,然后对其进行编辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM