用Dojo实行Confirm模式对话框

//用例

var dlg = this._ynDlg;
if (!dlg) {
dlg = this._ynDlg = new DialogYesNo({
whenYes: function () {alert("yes"); }
});
}
dlg.show("确认删除子账户吗?");
});

//源代码

//DialogYesNo.js

define([
"dojo/_base/declare",
"dijit/Dialog",
"dijit/_WidgetsInTemplateMixin",
"dojo/text!./templates/DialogYesNo.html",
"dijit/form/Button"
],function (declare,Dialog,_WidgetsInTemplateMixin,template) {
return declare([Dialog,_WidgetsInTemplateMixin],{
baseClass: "DialogYN",
templateString: template,
title: "确认",
whenNo: function () {
},
_no: function () {
this.hide();
this.whenNo();
},
whenYes: function () {
},
_yes: function () {
this.hide();
this.whenYes();
},
_keydown: function (event) {
var key = event.keyCode;
if (key === 78)
this._no();
else if (key === 89)
this._yes();
},
show: function (content) {
this.set("content",content);
this.inherited(arguments);
}
});
});

//./templates/DialogYesNo.html

<div class="dijitDialog" role="dialog" aria-labelledby="${id}_title"> <div data-dojo-attach-point="titleBar" class="dijitDialogTitleBar"> <span data-dojo-attach-point="titleNode" class="dijitDialogTitle" id="${id}_title" role="heading" level="1"></span> <span data-dojo-attach-point="closeButtonNode" class="dijitDialogCloseIcon" data-dojo-attach-event="ondijitclick: onCancel,keydown:_keydown" title="${buttonCancel}" role="button" tabIndex="-1"> <span data-dojo-attach-point="closeText" class="closeText" title="${buttonCancel}">x</span> </span> </div> <div data-dojo-attach-point="containerNode" class="dijitDialogPaneContent"> </div> <div style="background-color:#ffffff;min-width: 200px;height: 40px"> <div data-dojo-attach-point="buttonContainer" style="float: right;margin-right: 20px"> <button data-dojo-type="dijit/form/Button" data-dojo-attach-point="btnYes" data-dojo-attach-event="onClick:_yes">是(Y) </button> <button data-dojo-type="dijit/form/Button" data-dojo-attach-point="btnNo" data-dojo-attach-event="onClick:_no">否(N) </button> </div> </div> </div>

相关文章

我有一个网格,可以根据更大的树结构编辑小块数据.为了更容易...
我即将开始开发一款教育性的视频游戏.我已经决定以一种我可以...
我正在使用带有Grails2.3.9的Dojo1.9.DojoNumberTextBox小部...
1.引言鉴于个人需求的转变,本系列将记录自学arcgisapiforja...
我正在阅读使用dojo’sdeclare进行类创建的语法.描述令人困惑...
我的团队由更多的java人员和JavaScript经验丰富组成.我知道这...