【问题标题】:Telerik TreeView show a jquery modal instead of javascript confirm OnNodeDroppedTelerik TreeView 显示 jquery 模式而不是 javascript 确认 OnNodeDropped
【发布时间】:2011-10-17 23:54:14
【问题描述】:

有没有办法在 Treeview 中使用 jquery 对话框模式而不是 javascript 确认消息?当用户将一个节点拖到树上的另一个节点时,我正在执行客户端事件“OnClientNodeDropping”,我想要做的是显示一个 jquery 对话框,要求用户确认移动。我希望模态对话框的“确定”和“取消”按钮将值传递给 args.set_cancel(dialog_result);当我尝试此操作时,页面会在对话框返回 true 或 false 确认之前执行。如何将旧学校确认换成 jquery 模态对话框

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 
            args.set_cancel(dialog_result);
        }
    }

【问题讨论】:

    标签: jquery treeview telerik modal-dialog


    【解决方案1】:

    我立即注意到的一件事是您发布的代码使用的是 OnNodeDropped(或者至少这是函数的名称)而不是 OnClientNodeDropping。但是,假设这确实是您正在使用的功能,您真正需要添加的是检查对话框的结果。所以在你的例子中:

    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);
           }
        }
    }
    

    我相信使用这种方法应该允许脚本等待用户单击确定或取消。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-24
      • 2011-09-14
      • 2017-05-10
      • 1970-01-01
      • 2021-10-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多