繁体   English   中英

MDL模态对话框在模态背景后面单击

[英]MDL Modal Dialog click behind modal background

我已经从https://getmdl.io/components/#dialog-section使用Material Design Lite创建了一个模态对话框。 但是我面临一个问题,对话框外部的区域不可单击。

我在模态之外有一个注销按钮,我希望用户在要注销时单击它。 另外,我不想隐藏模式。

 $(document).ready(function() { var dialog = document.querySelector('#main-dialog'); if (! dialog.showModal) { dialogPolyfill.registerDialog(dialog); } dialog.showModal(); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <dialog class="mdl-dialog" id="main-dialog"> <h4 class="mdl-dialog__title">Select your .xlsx file:</h4> <div class="mdl-dialog__content"> <p> Your excel sheet must contain values in the form:<br/> <table border="1" style="margin:0 auto"> <tr> <td><font color="black"><b>PID No.</b></font></td> <td><font color="black"><b>Student Name</b></font></td> </tr> </table> </p> </div> <div class="mdl-dialog__actions"> <input id="list" type="file" required="yes" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"> </div> </dialog> 

如何使模式背景可点击?

要使对话框背景可点击,请使用dialog.show(); 而不是dialog.showModal();

$(document).ready(function() {
var dialog = document.querySelector('#main-dialog');
    if (! dialog.showModal) {
            dialogPolyfill.registerDialog(dialog);
    }
    dialog.show();
});

例子


从MDL文档:

 button.addEventListener('click', function() { dialog.showModal(); /* Or dialog.show(); to show the dialog without a backdrop. */ }); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM