简体   繁体   English

Twitter引导程序中模态窗口的层次结构

[英]Hierarchy of modal window in twitter bootstrap

I am using Twitter Boostrap framework in my project. 我在我的项目中使用Twitter Boostrap框架。 Currently I have a problem with using 2 modal windows in the same time. 目前,我在同时使用2个模态窗口时遇到问题。

Code looks like: 代码如下:

<div id="modal-dataset" class="modal hide fade in" style="display: none; ">
        <div class="modal-header">
            <a class="close" data-dismiss="modal">x</a>
            <h3>First</h3>
        </div>

        <div class="modal-body" id="modal-dataset-body">
                <div id="data-preview-buttons">
                    <button id="load_case" class="btn btn-primary" onclick="return loadNoteOrDataset();">Load second</button>
                </div>
        </div>

<div id="modal-dataset-preview" class="modal hide fade in" style="display: none">
        <div class="modal-header">
            <a class="close" data-dismiss="modal">x</a>
            <h3>Second</h3>

            <div class="modal-body" id="modal-dataset-preview-body">
                    Any text
            </div>
        </div>

In function loadNoteOrDataset() I use: 在函数loadNoteOrDataset()中,我使用:

$('#modal-dataset-preview').modal('show');

What is the problem? 问题是什么? First modal window appears and everything is fine, but when I want to call second window using button and 'show', it appears beneath first window, so I'm not able to see its content. 出现第一个模态窗口,一切都很好,但是当我想使用按钮和“显示”调用第二个窗口时,它出现在第一个窗口的下面,所以我看不到它的内容。

I want to build some kind of 'stack' of modal windows - new window should be visible after calling and when closed - previous window should be visible. 我想构建某种模式窗口的“堆栈”-调用后应显示新窗口,关闭时应显示-上一个窗口应可见。 Is there any way to set which window should be in front? 有什么方法可以设置哪个窗口应该在前面?

You could define diferent z-index values for each modal window. 您可以为每个模态窗口定义不同的z-index值。

$('#modal-dataset-preview').css('z-index', <value>).modal('show');

z-index MDN reference here . z-index MDN参考此处

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

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