我一页上有两个dijit对话框。一个是黑色的覆盖层,另一个是白色的。HTML是:
<div id="test" title="Colorful" dojoType="dijit.Dialog">
content
</div> 根据dijit的预期行为,它应该给出以下代码
<div dojoattachpoint="node" class="dijitDialogUnderlay _underlay" id="test_underlay"></div>其中,通过使用ID test_underlay,,我们可以定制覆盖背景。但是在我的例子中,我在运行时得到了下面的代码。
<div id="dijit_DialogUnderlay_0" class="dijitDialogUnderlayWrapper" widgetid="dijit_DialogUnderlay_0" style="display: block; top: 0px; left: 0px; opacity: 1;"><div dojoattachpoint="node" class="dijitDialogUnderlay" style="width: 1424px; height: 466px;"></div></div>知道为什么会这样吗?我的dojo版本是1.2
发布于 2011-11-14 11:50:10
在css中设置dijitDialogUnderlay类的背景颜色。如果由于某种原因,在css之前加载dojo,则可以添加!重要。
.dijitDialogUnderlay.white_underlay {
background: none repeat scroll 0 0 #FFFFFF !important;
}
.dijitDialogUnderlay.black_underlay {
background: none repeat scroll 0 0 #000000 !important;
}在您的标记中:
<div id="test" title="Colorful" dojoType="dijit.Dialog" class="black">content</div>
<div id="test" title="Colorful" dojoType="dijit.Dialog" class="white">content</div>发布于 2011-11-14 15:47:18
试试这个:
<html>
<head>
<script type="text/javascript">
var underlay = dijit._underlay;
dojo.addOnLoad(function(){
if(!underlay){
underlay = dijit._underlay = new dijit.DialogUnderlay();
}
var whiteDialog = dijit.byId("test");
var blackDialog = dijit.byId("test2");
dojo.connect(btn1, "onClick", function(e){ whiteDialog.show(); });
dojo.connect(btn2, "onClick", function(e){ blackDialog.show(); });
});
</script>
</head>
<body>
<div jsId="btn1" dojoType="dijit.form.Button">Show white dialog</div>
<div jsId="btn2" dojoType="dijit.form.Button">Show black dialog</div>
<div id="test" title="White" dojoType="dijit.Dialog">
content
<script type="dojo/connect" event="onShow">
dojo.style(underlay.domNode.firstChild, "backgroundColor", "white");
</script>
</div>
<div id="test2" title="Black" dojoType="dijit.Dialog">
content
<script type="dojo/connect" event="onShow">
dojo.style(underlay.domNode.firstChild, "backgroundColor", "black");
</script>
</div>
</div>
</body>
</html>https://stackoverflow.com/questions/8118162
复制相似问题