简体   繁体   English

Bootstrap Modal在关闭然后打开后不滚动

[英]Bootstrap Modal Not scrolling after close then open

I have a function the when clicked closes the active modal, then right away opens the one that was clicked on based on the modal IDs. 我有一个函数,当单击时会关闭活动模式,然后立即基于模式ID打开被单击的模式。

$("#"+currentModal).modal('hide');

$("#"+name).modal({keyboard:false,backdrop:'static'});
$("#"+name).modal('show');

But when the second modal is opened it does not scroll. 但是,当第二个模式打开时,它不会滚动。 The modal is bigger than the window and the scroll bar scrolls the page grayed out behind the modal. 模态大于窗口,并且滚动条滚动页面到模态后面变灰的页面。

But the first modal is also bigger than the window but the scroll bar acts as it should. 但是第一个模态也比窗口大,但滚动条会按其应有的方式工作。 Is there something wrong with closing and then opening a modal right away? 立即关闭然后打开模式有什么问题吗? The right modals are being opened and closed so the problem is not the IDs being passed but the only issue is the scroll bar not being with the modal. 正确的模态正在打开和关闭,因此问题不在于传递ID,而是唯一的问题是滚动条不与模态一起使用。

If both the modals show fine individually, it could be due to a conflict with operations. 如果两个模式分别显示正常,则可能是由于与操作冲突。 Try to show the second modal on event hidden.bs.modal of first modal. 尝试在第一个模态的事件hidden.bs.modal上显示第二个模态。

$("#"+currentModal).on('hidden.bs.modal', function () {
          $("#"+name).modal({keyboard:false,backdrop:'static'});
          $("#"+name).modal('show');
    });

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

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