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

标签 css html dojo

我使用 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/

相关文章:

javascript - dojox.grid.DataGrid 通过列的值选择行

dojo - 动态隐藏 dgrid 中的列

html - SVG 边框以特定宽度截断

android - 用于自定义选择按钮的 ionic 框架

html - 是否可以对 iframe 的内容进行硬编码?

php - 使用 cakephp 从存储过程中获取 try/catch

dojo - dojo列表框控件

css - 如果存在正确的字体,如何使用 CSS 仅显示文本?

javascript - 在 Chrome 中设置动画时隐藏的 Angular 落变得可见

javascript - 在 div 之间转换时显示加载图标