4

Is there an option on the jstree check callback or dnd plug-ins that will only copy the children of a folder over, when a folder is dragged to another tree? I want to copy just the children inside the folder when copying it and not the folder as well. Thanks.

NiallMitch14
  • 1,198
  • 1
  • 12
  • 28

1 Answers1

2

Solved this problem by using an on copy_node event to move each file in the folder up in the tree after the copy and delete the folder after all files are moved out of it

$('#tree').on("copy_node.jstree", function(e, data){
        if(data.node.icon.indexOf("folder")!=-1){
            var children = data.node.children;
            while(children.length > 0){
                var node = $('#tree').jstree().get_node(children[0]); 
                $('#tree').jstree("move_node", node, "#", "before");
            }
            $('#tree').jstree("delete_node", data.node.id);
        }
}
NiallMitch14
  • 1,198
  • 1
  • 12
  • 28