我使用 the example 创建了一个 dojo 对话框.我在后台使用 map 。问题是当对话框出现时,背景被遮挡,我无法使用 map (没有底层的对话框)。有什么办法可以在后台出现对话框时启用使用背景?
最佳答案
你可以通过一些技巧来做到这一点:
require(["dijit/Dialog", "dijit/DialogUnderlay", "dojo/domReady!"], function(Dialog, DialogUnderlay){
//just for the snippets to get the right styling
document.body.className = "tundra";
myDialog = new Dialog({
title: "My Dialog",
content: "Test content.",
style: "width: 300px"
});
myDialog2 = new Dialog({
title: "My Dialog",
content: "Test content.",
style: "width: 300px"
});
showDialog2 = function () {
myDialog2.show().then(function() {
DialogUnderlay.hide()
//little hack to avoid JS error when closing the dialog
DialogUnderlay._singleton.bgIframe = {destroy: function() {}}
});
}
});
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
<link rel="stylesheet" type="text/css" href="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/resources/dojo.css">
<link rel="stylesheet" type="text/css" href="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/tundra/tundra.css">
<button onclick="myDialog.show();">show with underlay</button>
<button onclick="showDialog2();">show without underlay</button>
关于css - 出现对话框时如何启用背景元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31286343/