I developed a warning warning that appears
do you want to move this file or folder ?
if I click no: it will return to the default folder.
if yesit goes to a new folder.
So my problem is when I drag the parent folder , a confirmation message appears and, if I click no, the movement does not stop, this means that the folder will be moved to a new folder
For example, I have:
In my jstree, I have the nodes Root1 and Root2 , which are the parent nodes, so when I move child1 to Root2, it works fine. but when I move ROOT2 to ROOT1, it did not stop moving when I pressno
This is my code:
$('#tree').jstree({
"core" : {
"animation" : 0,
"check_callback" : true,
"data" : [
{ "id" : "ajson1", "parent" : "#", "text" : "Simple root node" },
{ "id" : "ajson11", "parent" : "#", "text" : "Simple root 1 node" },
{ "id" : "ajson12", "parent" : "#", "text" : "Simple root 2 node" },
{ "id" : "ajson2", "parent" : "#", "text" : "Root node 2" },
{ "id" : "ajson3", "parent" : "ajson2", "text" : "Child 1","type" : "file" },
{ "id" : "ajson4", "parent" : "ajson2", "text" : "Child 2","type" : "file" },
]
},
"types" : {
"#" : {
"max_children" : 1,
"max_depth" : 4,
"valid_children" : ["root"]
},
"root" : {
"icon" : "/static/3.1.1/assets/images/tree_icon.png",
"valid_children" : ["default"]
},
"default" : {
"valid_children" : ["default","file"]
},
"file" : {
"icon" : "glyphicon glyphicon-file",
"valid_children" : []
}
},
"plugins" : [
"contextmenu", "dnd", "types"
]
});
var Parent = 0;
var newParent = 0;
var Pos = 0;
var newPos = 0;
$(document).on('dnd_start.vakata', function (event, data) {
sel = "li#"+ data.data.nodes[0] +".jstree-node";
Parent = $('#tree').jstree(true).get_node(data.data.nodes[0]).parent;
Pos = $(sel).index();
});
$(document).on('dnd_stop.vakata', function (event, data) {
node = data.data.origin.get_node(data.data.nodes[0]);
if (node.type == "root")
{
return false;
}
if (confirm("Voulez vous vraiment deplacer le fichier ou le dossier ?") === false)
{
$('#tree').jstree(true).move_node(node,Parent,Pos);
return false;
}
sel = "li#"+ data.data.nodes[0] +".jstree-node";
newPos = $(sel).index();
newParent = node.parent;
});
and this is an example