This question展示了如何在Dojo中的程序化ConfirmDialog
上隐藏取消按钮。
如果Cancel
在HTML模板中声明如下,如何做同样的事情,即隐藏ConfirmDialog
按钮:
<div class="confirmDialog"
data-dojo-type="dijit/ConfirmDialog"
data-dojo-attach-point="confirmDialogAttachPoint"
data-dojo-props="title:'MyDialog', content:'Some Content', closable:false"
data-dojo-attach-event="onExecute:doSomething">
</div>
在相应小部件的postCreate
函数中执行以下操作:
domStyle.set(this.confirmDialogAttachPoint.cancelButton.domNode, "display", "none");
但是,我想知道/了解这是否可以在HTML文件本身中以声明方式完成。
只需在你的widget css中添加一个css就会隐藏你的按钮:
.dijitDialogPaneActionBar .dijitButton:nth-child(2) {
display: none;
}
见下面的片段:
require(["dijit/ConfirmDialog", "dijit/form/TextBox", "dijit/form/Button"]);
.dijitDialogPaneActionBar .dijitButton:nth-child(2) {
display: none;
}
<script type="text/javascript">
dojoConfig = {
isDebug: true,
async: true,
parseOnLoad: true
}
</script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
<link href="//ajax.googleapis.com/ajax/libs/dojo/1.8.3/dijit/themes/claro/claro.css" rel="stylesheet" />
<body class="claro">
<div data-dojo-type="dijit/ConfirmDialog" data-dojo-id="myDialog" title="dialog">
Hi !
</div>
<button data-dojo-type="dijit/form/Button" type="button" onClick="myDialog.show();">
Show me!
</button>
</body>