Telerik TreeView show a jquery modal instead of javascript confirm OnNodeDropped
Is there a way to use a jquery dialog modal instead of the javascript confirm message with the Treeview? When a user drags a node to another on a tree I am executing the client side event "OnClientNodeDropping", what I want to do is show a jquery dialog asking the user to confirm the move. I would want the OK and Cancel button of the modal dialog to pass a value to args.set_cancel(dialog_result); When I try this the page execute before the dialog can return a true or false confirmation. How can I swap out the old school confirm for a jquery modal dialog
function OnNodeDropped(sender, args) {
var srcNode = args.get_sourceNode();
var destNode = args.get_destNode();
var dNode = destNode._contentElement.innerHTML.indexOf("inActiveCategory");
if (dNode >= 0) {
//Call a modal dialog here and return true of false instead of using the old school confirm
var result = confirm("This category is inactive. Moving to " + destNode.get_text() + " will set " + srcNode.get_te开发者_JAVA技巧xt() + " to inactive as well! ");
//get the return value from the dialog, is it canceled or ok
args.set_cancel(dialog_result);
}
}
One thing that I immediately noticed is that the code you posted is using the OnNodeDropped (or at least that's the name of the function) and not OnClientNodeDropping. However, assuming that this is indeed the function that you are using all you really should need to add is a check for the result from the dialog. So in your example:
function OnNodeDropped(sender, args) {
var srcNode = args.get_sourceNode();
var destNode = args.get_destNode();
var dNode = destNode._contentElement.innerHTML.indexOf("inActiveCategory");
if (dNode >= 0) {
//Call a modal dialog here and return true of false instead of using the old school confirm
var result = confirm("This category is inactive. Moving to " + destNode.get_text() + " will set " + srcNode.get_text() + " to inactive as well! ");
//get the return value from the dialog, is it canceled or ok
if(result){
args.set_cancel(false);
}
else{
args.set_cancel(true);
}
}
}
I believe using this approach should allow for the script to wait for the user to click OK or Cancel.
精彩评论