出现对话框时如何启用背景元素?

How can i enable use of background elements when the dialog is appeared?

我使用 the example 创建了一个 dojo 对话框。我在后台使用地图。问题是当对话框出现时,背景被遮挡,我无法使用地图(没有底层的对话框)。有什么方法可以在后台出现对话框时启用使用后台?

你可以通过一些技巧来完成:

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>