gpt4 book ai didi

javascript - 在关闭另一个 Bootstrap 模式后打开 Bootstrap 模式 - 意外行为

转载 作者:行者123 更新时间:2023-12-01 05:51:29 25 4
gpt4 key购买 nike

我想在用户关闭另一个后立即显示 Bootstrap 模式。所以我使用以下代码尝试执行此操作:

currentModal.modal('hide').on('hidden.bs.modal', function (){
nextModal.modal('show');
});

一切都正常发生。第一个模式关闭,下一个模式出现。

但是,class="modal-open" 应该位于 body 元素中才能正常滚动,但没有发生什么。显示第二个模态后,该类从 body 中消失。

我做错了什么吗?

最佳答案

Am I doing something wrong?

我不这么认为。 large number of issues on this topic表明这要么设计得不好,要么不是为了支持这一点而设计的。相关错误为 Multiple modals fix #5022 , Multiple modals #11872 .modal-open is not applied to body when "switching" to another modal #11865 @mdo 明确表示:

Yup, we won't be supporting multiple modals.

So what to do about it?

一个小的超时肯定会有帮助:

currentModal.modal('hide').on('hidden.bs.modal', function (){
setTimeout(function() {
nextModal.modal('show');
}, 100);
});

关于javascript - 在关闭另一个 Bootstrap 模式后打开 Bootstrap 模式 - 意外行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21743509/

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