0

I have a jquery dialog window where the user can provision a new server with different requirements. Now, when the user clicks 'Save' we want a confirmation window to open up to confirm that the user wants to do this.

My main concern is that this is a dialog box within a dialog box.

Here is the code for the dialog box

$('#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
});

Thanks :)

4

1 回答 1

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

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

于 2013-09-13T21:11:47.897 回答