JStree - copy only files with folders on dnd

Is there an option for jndree checkback or dnd plug-ins that will only copy files from a folder when the folder is dragged to another tree? I want to copy only children inside the folder when copying, not to the folder. Thanks.

+4
source share
1 answer

Solve this problem by using the copy_node event to move each file in a folder up the tree after copying and deleting the folder after all files are deleted from 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);
        }
}
+2
source

Source: https://habr.com/ru/post/1619869/


All Articles