如何在一个引导模式从另一个模式打开滚动功能

How to have the scroll functionality in a Bootstrap modal opened from another modal?

本文关键字:模式 另一个 功能 滚动 一个      更新时间:2023-09-26

我目前有两个按钮在一个Bootstrap Modal:

<button type="button" class="left_portfolio_item portfolio_controls"></button>
<button id="to_modal_two" type="button" class="right_portfolio_item portfolio_controls"></button>

第二个id为to_modal_two的,当点击时,应该关闭第一个模态(他所在的模态),打开第二个模态。
为了实现这一点,我使用jQuery:

$('#to_modal_two').click(function() {
    $('#modal_one').modal('hide');
    $('#modal_two').modal('show');
});

第一个模态正在关闭,第二个模态正在打开,但不幸的是,我不能在其中使用滚动功能。
是否有任何变通办法来实现我正在寻找的?

这是我试图使它像我想要的那样工作:

$('#to_modal_two').click(function() {
    $('body').removeClass('modal-open');
    $('body').css("padding-right","");
    $('#modal_one').removeClass('in');
    $('#modal_one').css("display","");
    $('#modal_one').attr("aria-hidden","true");
    $('.modal-backdrop').hide();
    $('#modal_two').modal('show');
});

一个错误,我还没有弄清楚如何修复它是,我关闭第二个模态访问第一个使用"正常方式"(<button type="button" data-toggle="modal" data-target="#modal_one"></button>)后,我必须做2或3点击它打开模态。

相关文章: