Problem on drag and drop validation in onDrag()

Hi,

I am having the following problem:

I need to show a confirm alert whenever the users moves a tree node from one place to another (something like “Are you sure do you want to move the node? yes/no”).

I am using the onDrag to add my validation:

tree2.attachEvent(“onDrag”, function(sId,tId,id,sObject,tObject) {
return validateMove(sId, tId);
});

My function for validating is something like this:

function validateMove(sId, tId) {
var flag = allowedToMove(sId, tId);
if(flag){
flag = confirm("Do you want to move " + tree2.getItemText(sId) + “?”);
}else{
alert(“Moving " +tree2.getItemText(sId)+ " is not allowed due to specific rule!”);
}
return flag;
}

The problem is that when the confirm appears and the users clicks on cancel. The layout becomes corrupt like I show in the image. (see that the black line that appears while holding the mouse click still remains).

Anyone has an idea of how to solve this?

Thanks in advance

Hi

My little working sample for you:

[code] tree = new dhtmlXTreeObject(“tree_1”,“100%”,“100%”,0);
tree.setSkin(‘dhx_skyblue’);
tree.setImagePath("…/dhtmlxTree_prof/codebase/imgs/csh_bluefolders/");
tree.enableSmartXMLParsing(true);
tree.enableDragAndDrop(true); //any
tree.loadXML("…/___xml/tree_dnd.xml");
tree.attachEvent(“onDrag”, function(sId,tId,id,sObject,tObject){
if (confirm(“Yes/No?”)) {
return true
} else {
return false
}

    });

    tree2 = new dhtmlXTreeObject("tree_2","100%","100%",0);
    tree2.setSkin('dhx_skyblue');
    tree2.setImagePath("../dhtmlxTree_prof/codebase/imgs/csh_bluefolders/");
    tree2.enableSmartXMLParsing(true);
    tree2.enableDragAndDrop(true);
    tree2.setDragBehavior("sibling");
    tree2.loadXML("../___xml/tree_dnd.xml");[/code]

It seems to me that confirm (as an alert) can interrupt the drug movement.