Dojo 声明式 ConfirmDialog 隐藏取消按钮
Dojo declarative ConfirmDialog hiding cancel button
展示了如何在 Dojo 中隐藏编程 ConfirmDialog
上的取消按钮。
如何做同样的事情,即隐藏 Cancel
按钮,如果 ConfirmDialog
在 HTML 模板中如下声明:
<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 文件本身中以声明方式完成,我想 know/learn。
只需将 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>
ConfirmDialog
上的取消按钮。
如何做同样的事情,即隐藏 Cancel
按钮,如果 ConfirmDialog
在 HTML 模板中如下声明:
<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 文件本身中以声明方式完成,我想 know/learn。
只需将 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>