Modal正在使用bootstrap4 alpha6模式转换错误

Cai*_*der 7 javascript jquery modal-dialog bootstrap-4

我正在使用bootstrap4 alpha 6 Modal,我得到:

Error: Modal is transitioning
Run Code Online (Sandbox Code Playgroud)

当我尝试通过JavaScript函数再次使用动态数据重新触发相同的模态时,会发生这种情况,如下所示:

function openModal(title, text) {
    $('.modal-title').text(title);
    $('.modal-body p').text(text);
    $('#modalAlert').modal('show');
}
Run Code Online (Sandbox Code Playgroud)

我尝试使用setTimeout函数,但没有像本文中那样工作:https: //github.com/twbs/bootstrap/issues/21687

有什么建议?

Emi*_*nte 8

最快的解决方案是删除抛出此错误的模态'淡入淡出'类.这似乎是Bootsrap v6的一个已知问题,将在下一次发布时修复.

看到这里


小智 0

我也在使用 bootstrap 4 Modal,我的解决方案;

    $(document).on('show.bs.modal', '.modal', function (event) {
        var zIndex = 1040 + (10 * $('.modal:visible').length);
        $(this).css('z-index', zIndex);
        setTimeout(function() {
            $('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
        }, 0);
    });
Run Code Online (Sandbox Code Playgroud)