如何在dojo中创建确认对话框?我想有一个确定取消对话框出现在按钮单击与dojo对话框(没有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>
如何制作这个ok取消对话框?
答案 0 :(得分:2)
<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 :(得分:2)
自Dojo 1.10起支持Confirm Dialog。
答案 2 :(得分:0)
上述解决方案未考虑对话框右上角的小十字。
很久以前,我做过一小段对话,你可能会在这里找到一些快乐,特别是ConfirmDialog.js 我今天刚刚将它们上传到github,所以你可以看看它们:http://github.com/PEM-FR/Dojo-Components/tree/master/dojox/dialog
它们应该“按原样”使用或稍作修改