在道场中确认对话框

confirm dialog in dojo

本文关键字:确认 对话框      更新时间:2023-09-26

如何在道场中创建确认对话框?我想在带有道场对话框的按钮单击时出现一个确定的取消对话框(没有javascript确认对话框)。到目前为止,我只能在单击事件上显示一个对话框。这是我的代码:

<script type="text/javascript">
dojo.require("dijit.form.Button");
dojo.require("dijit.Dialog");
var secondDlg;
dojo.ready(function(){
    // create the dialog:
    secondDlg = new dijit.Dialog({
       title: "Programmatic Dialog Creation",
       style: "width: 300px",
   draggable:false
    });
});
showDialogTwo = function(){
   // set the content of the dialog:
   secondDlg.set("content", "Hey, I wasn't there before, I was added at " + new Date() + "!");
   secondDlg.show();
}
</script>
</head>
<body class="claro" style="margin-right:10px;">
<button id="buttonTwo" data-dojo-type="dijit.form.Button" data-dojo-props="onClick:showDialogTwo" type="button">Show me!</button>
</body>

如何使此"正常取消"对话框?

<script type="dojo/method" event="onClick">
                    var dialog = new dijit.Dialog({
                        title: "Delete Switch Type",
                        style: "width: 400px",
                        content : "Do you really want to delete ?????<br>"
                    });
                   //Creating div element inside dialog
                    var div = dojo.create('div', {}, dialog.containerNode);
                    dojo.style(dojo.byId(div), "float", "left");
                    var noBtn = new dijit.form.Button({
                                label: "Cancel",
                                onClick: function(){
                                    dialog.hide();
                                    dojo.destroy(dialog);
                                }
                             });
                    var yesBtn = new dijit.form.Button({
                                label: "Yes",
                                style : "width : 60px",
                                onClick : <your function here>,
                                dialog.hide();
                    dojo.destroy(dialog);
                                }
                             });
                                  //adding buttons to the div, created inside the dialog
                    dojo.create(yesBtn.domNode,{}, div);
                    dojo.create(noBtn.domNode,{}, div);
                    dialog.show();
                </script>

我将此代码用作内联道场/方法 - 在按钮的单击事件上。 你仍然可以修改

从 Dojo 1.10 开始支持确认对话框。

请参阅发行说明和文档。

上面的解决方案没有考虑对话框右上角的小十字。

很久以前,我做过一小套对话,你可能会在这里找到一些快乐,尤其是确认对话.js我今天刚刚将它们上传到github上,所以你可以看看它们:http://github.com/PEM-FR/Dojo-Components/tree/master/dojox/dialog

它们应该"按原样"可用或稍作更改