Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Twitter bootstrap 打开第二个模式后,引导框模式不可滚动_Twitter Bootstrap_Bootstrap Modal_Bootbox - Fatal编程技术网

Twitter bootstrap 打开第二个模式后,引导框模式不可滚动

Twitter bootstrap 打开第二个模式后,引导框模式不可滚动,twitter-bootstrap,bootstrap-modal,bootbox,Twitter Bootstrap,Bootstrap Modal,Bootbox,JS小提琴: 我最初创建的是一个引导对话框: // First dialog bootbox.dialog({ message: '<input type="button" value="Open second modal" class="second" />' + '<br/>bar'.repeat(100), allowCancel: true }); 创建另一个引导对话框/警报/提示并将其关闭后,滚动不再影响第一个对话框。网页内容移动,第一个对话框

JS小提琴:

我最初创建的是一个引导对话框:

// First dialog
bootbox.dialog({
    message: '<input type="button" value="Open second modal" class="second" />' + '<br/>bar'.repeat(100),
    allowCancel: true
});
创建另一个引导对话框/警报/提示并将其关闭后,滚动不再影响第一个对话框。网页内容移动,第一个对话框保持冻结状态(意外行为)。我该如何解决这个问题


可以单击第一个对话框中可见的任何按钮,主页上的按钮不可单击(预期行为)。

引导模式由单模式查看组成,但是,如果我们想在模态上显示模态,那么当当前模态关闭时,dom将被重置,并且从body标签
模态打开
将被删除,这将导致滚动问题

解决方案1

当第二个模态在
模态关闭时,打开车身

 $('.bootbox.modal').on('hidden.bs.modal', function () {
  if($(".modal").hasClass('in')){
             $('body').addClass('modal-open');
         }
})

解决方案2

使用css也可以实现同样的效果

.bootbox.modal{
  overflow: auto !important;
}
这将使模态可滚动,但将有2个滚动条


-帮助:)

根据帮助回答,在引导程序4中,您必须使用

$(document).on('hidden.bs.modal', '.bootbox.modal', function (e) {    
        if($(".modal").hasClass('show')) {
            $('body').addClass('modal-open');
        }
})

在bootstrap 3中,您必须使用以下代码:

$(document).on('hidden.bs.modal', '.bootbox.modal', function (e) {    
        if($(".modal").hasClass('in')) {
            '$('body').addClass('modal-open');
        }
});
$(document).on('hidden.bs.modal', '.bootbox.modal', function (e) {    
        if($(".modal").hasClass('in')) {
            '$('body').addClass('modal-open');
        }
});