首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >按下对话框“保存”按钮后创建对话框确认

按下对话框“保存”按钮后创建对话框确认
EN

Stack Overflow用户
提问于 2013-09-13 19:27:58
回答 1查看 1.3K关注 0票数 0

我有一个jquery对话框窗口,用户可以在其中提供具有不同需求的新服务器。现在,当用户单击“Save”时,我们希望打开一个确认窗口,以确认用户希望这样做。

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

下面是对话框的代码

代码语言:javascript
复制
$('#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
});

谢谢:)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-13 21:11:47

你可以这样做:

HTML:

代码语言:javascript
复制
<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:

代码语言: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");
        }
    }
});

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18793812

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档