gpt4 book ai didi

jquery - Bootstrap 模式对话框可以覆盖另一个对话框吗?

转载 作者:技术小花猫 更新时间:2023-10-29 10:56:21 25 4
gpt4 key购买 nike

<button class="btn" onClick="$('#firstModal').modal('show');">First</button>

<!-- Modal -->
<div id="firstModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-body">
<button class="btn" onClick="$('#secondModal').modal('show');">Second</button>
</div>
</div>

<!-- Modal -->
<div id="secondModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-body">
Some error message goes here.
</div>
</div>

一切正常;唯一的问题是第一个对话框显示在第二个对话框的叠加层上。我该如何解决这个问题?

现在是这样的: enter image description here

我希望它看起来像这样: enter image description here

最佳答案

我写了一篇关于如何以编程方式解决这个堆叠问题的博文:http://gurde.com/stacked-bootstrap-modals/

$(document)  
.on('show.bs.modal', '.modal', function(event) {
$(this).appendTo($('body'));
})
.on('shown.bs.modal', '.modal.in', function(event) {
setModalsAndBackdropsOrder();
})
.on('hidden.bs.modal', '.modal', function(event) {
setModalsAndBackdropsOrder();
});

function setModalsAndBackdropsOrder() {
var modalZIndex = 1040;
$('.modal.in').each(function(index) {
var $modal = $(this);
modalZIndex++;
$modal.css('zIndex', modalZIndex);
$modal.next('.modal-backdrop.in').addClass('hidden').css('zIndex', modalZIndex - 1);
});
$('.modal.in:visible:last').focus().next('.modal-backdrop.in').removeClass('hidden');
}

关于jquery - Bootstrap 模式对话框可以覆盖另一个对话框吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16547650/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com