jstree move, drag and drop

前端 未结 3 605
暗喜
暗喜 2021-02-02 17:26

I want to implement the move functionality for a node in jstree. Is it the move that needs to be implemented or the drag and drop? Also, it would be nice to have working code f

3条回答
  •  南方客
    南方客 (楼主)
    2021-02-02 17:56

    $("#demo1").jstree({
    ....
    .bind("move_node.jstree", function (e, data) {
    
        /*
        requires crrm plugin
    
        .o - the node being moved
        .r - the reference node in the move
        .ot - the origin tree instance
        .rt - the reference tree instance
        .p - the position to move to (may be a string - "last", "first", etc)
        .cp - the calculated position to move to (always a number)
        .np - the new parent
        .oc - the original node (if there was a copy)
        .cy - boolen indicating if the move was a copy
        .cr - same as np, but if a root node is created this is -1
        .op - the former parent
        .or - the node that was previously in the position of the moved node */
    
        var nodeType = $(data.rslt.o).attr("rel");
        var parentType = $(data.rslt.np).attr("rel");
    
        if (nodeType && parentType) {
            // TODO!
        }
    })
    });
    

提交回复
热议问题