我在对话框中显示了一个网格,没有任何问题。但问题是,对话框在后台阻塞了整个页面。有什么方法可以避免它吗?也就是说,一旦显示对话框,用户仍然可以访问页面元素,如Tab等。
发布于 2017-01-11 20:19:23
这可以通过使用CSS来实现。当您创建一个Dialog
并为其赋予id
属性时,它将创建一个跨越整个页面的底层<div>
,因此,除了这个新的底层<div>
之外,您不能单击任何东西。幸运的是,您可以使用CSS隐藏这样的元素,并且因为元素的ID是作为#<ID of dialog>_underlay
生成的,所以您可以简单地这样做:
require(['dijit/Dialog', 'dijit/form/Button', 'dojo/domReady!'], function(Dialog, Button) {
var dialog = new Dialog({
id: 'test',
title: 'Test',
content: 'Hello world'
});
new Button({}, 'btn').on('click', function() {
dialog.show();
});
});
/* "test" is the ID of the dialog, so I need to use #test_underlay */
#test_underlay {
/* Setting this property to none hides the element */
display: none;
}
<head>
<link href="https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dijit/themes/claro/claro.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js" data-dojo-config="async: false"></script>
</head>
<body class="claro">
<button id="btn">Click me</button>
<input type="checkbox" />Can you still select me?
</body>
发布于 2017-04-11 22:56:22
您可以使用Dojo的FloatingPane来代替对话框。它的工作方式大致相同,您可以使用它下面的对象。
https://stackoverflow.com/questions/41580540
复制相似问题