Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by John Watson on Jun 27, 2008 13:05
open dhtmlx forum
Ask for confirmation before update/ insert/ delete of tree node

I have set up a "Recycle" node  on my tree so that if you drag an item into it, it shall delete. However I need a confirm box to show, i am using the following code:

 myDataProcessor.setOnBeforeUpdateHandler(function(nodeId,cType){
                return confirm("Are you sure you want to " + cType + " this item?") ;
});

However if I select CANCEL it still runs the update and deletes the item.

How can I pass the return value and cancel the update?

Thanks

John

Answer posted on Jun 28, 2008 03:23
a) you need to update to latest version of dataprocessor ( contact us directly at support@dhtmlx.com ), in which next code will work

 myDataProcessor.setOnBeforeUpdateHandler(function(nodeId,cType){
    if (!confirm("Are you sure you want to " + cType + " this item?")){
       myDataProcessor.setUpdated(nodeId,false);
       return false;
    } else
             return true;
});


or you can use onDrag event instead of onBeforeUpdate, and add confirmation to that event