Dojo声明ConfirmDialog隐藏取消按钮

问题描述 投票:0回答:1

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文件本身中以声明方式完成。

javascript dialog dojo
1个回答
0
投票

只需在你的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>
© www.soinside.com 2019 - 2024. All rights reserved.