【问题标题】:Creating a dialog confirmation after a dialog 'save' button is pressed按下对话框“保存”按钮后创建对话框确认
【发布时间】:2013-09-13 19:27:58
【问题描述】:

我有一个 jquery 对话窗口,用户可以在其中配置具有不同要求的新服务器。现在,当用户点击“保存”时,我们希望打开一个确认窗口以确认用户想要执行此操作。

我主要关心的是这是对话框中的一个对话框。

这是对话框的代码

$('#newenvironment').dialog({
    autoOpen: false,
    buttons: {
        'Save': function() {
            var url = "./environment/new/";

            // There is code here that processes the fields

            // code to send the data to the server

            // URL gets built
            c.post(url);

            $('#newenvironment').dialog('close');
        },
        'Cancel': function() {
            $('#newenvironment').dialog('close');
        }
    },
    modal: true,
    width: 640
});

谢谢:)

【问题讨论】:

    标签: javascript jquery dialog confirm


    【解决方案1】:

    您可以按照以下方式进行操作:

    HTML:

    <div id="mainDialog">
        <div id="area">
           <h2>Server requirements </h2>
           Enter something: <input type="text" name="yada"/>
        <div>
    </div>
    
    <div id="confirmDialog">Are you sure?</div>
    

    Javascript:

    $("#confirmDialog").dialog({
        height: 250,
        modal: true,
        autoOpen: false,
        buttons: {
            "Yes": function() {
                $(this).dialog("close");
    
                // show some sort of busy indicator here
    
                var url = "./environment/new";
                // code to process inputs from main dialog
                //c.post(url);
    
                // clear busy indicator here
            },
            "No": function() {
                $(this).dialog("close");
                $("#mainDialog").dialog("open"); 
            }
        }
    });
    
    $("#mainDialog").dialog({
        height:350,
        modal: true,
        autoOPen: false,
        buttons: {
            "Save": function() {
                $(this).dialog("close");  
                $("#confirmDialog").dialog("open");
            },
            "Cancel": function() {
                $(this).dialog("close");
            }
        }
    });
    

    这将在显示确认对话框时关闭主对话框,如果您不确认则重新打开它。或者,您可以在确认对话框打开时保持主对话框打开。在这种情况下,主对话框将被阻止,直到用户退出确认对话框。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-01
      • 1970-01-01
      • 2015-11-16
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多