简体   繁体   English

如何在另一个引导程序模式位置上显示引导程序模式对话框

[英]How to show bootstrap modal dialog over another bootstrap modal position

How to show bootstrap modal dialog over another bootstrap modal I have one modal dialogue on button click of modal I open another modal window which show after that window and over first modal ? 如何在另一个引导程序模态上显示引导程序模态对话框我在模态的按钮单击上有一个模态对话框我打开另一个模态窗口,该窗口显示在该窗口之后和第一个模态上? I tried with z-index but it is not working. 我尝试使用z-index,但无法正常工作。

You should take a look at this repo : https://github.com/jschr/bootstrap-modal/ 您应该看看这个仓库: https : //github.com/jschr/bootstrap-modal/

It extends Bootstrap'modal plugin to allow multiple modal (and other things) 它扩展了Bootstrap的模态插件,以允许多种模态(和其他功能)

This solution is very dirty, my scenario was that a form inside a modal submits via ajax, if the response is late I wanted to put another overlay and another modal saiyng "sorry i'm late" 该解决方案非常脏,我的情况是模态内部的一个表单通过ajax提交,如果响应晚了,我想放另一个叠加层和另一个模态saiyng“对不起,我来晚了”

$('body').prepend('<div id="signup-box" class="ajax-is-late widget-box modal-dialog visible"><div class="modal-content"><div class="modal-body"><span style="font-size:25px; margin-left:20px;">bla bla bla...</span></div></div></div><div class="my-dirty-solution modal-backdrop fade in" style="z-index: 1041;"></div>');

as you can see, the overlay i'm creating has a z-layout that is higher than the one of standard bootstrap modals (1040) 如您所见,我正在创建的叠加层的z布局高于标准的引导程序模态(1040)

<div class="my-dirty-solution modal-backdrop fade in" style="z-index: 1041;"></div>

Both, the overlay and the modal that I added could be accessed and destroyed with 我添加的叠加层和模式都可以通过以下方式访问和销毁

$('.my-dirty-solution').remove();

You could see it in action this way: 您可以通过以下方式看到它:

  • open with Chrome the page 使用Chrome打开页面
  • open the real bootstrap modal 打开真正的引导程序模态
  • open Chrome Dev Console 打开Chrome开发者控制台
  • paste my code and press ENTER 粘贴我的代码,然后按Enter

Remember, it's a very dirty and cheeky solution... ;) 记住,这是一个非常肮脏和厚脸皮的解决方案...;)

Add these css classes: 添加以下CSS类:

 .first-level-dialog {
    z-index: 1060;
}

.second-level-dialog {
    z-index: 1040 !important;
}

The first one add to the dialog container (this one with modal css class) that you want to have on first plan (above other). 第一个添加到您要在第一个计划(另一个计划)上拥有的对话框容器(此对话框具有模式css类)。

Finally add handlers for dialog events: 最后为对话框事件添加处理程序:

$(document).on('shown.bs.modal', '#modalid', function (e) {
        $('.modal:not(.first-level-dialog)').addClass('second-level-dialog');
    });

    $(document).on('hide.bs.modal', '#modalid', function (e) {
        $('.modal').removeClass('second-level-dialog');
    });

As #modalid set id of the modal you want to have on first plan (the one with the first-level-dialog css class specified) 由于#modalid设置了您要在第一个计划上使用的模态的ID(已指定了第一级对话框CSS类的模态)

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

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