Bootstrap Modal Backdrop Remaining

前端 未结 24 2084
被撕碎了的回忆
被撕碎了的回忆 2020-12-23 08:55

I am showing a Bootstrap modal window for loading when performing AJAX calls. I broadcast a \"progress.init\" event when the loading modal should show and a \"progress.finis

24条回答
  •  暖寄归人
    2020-12-23 09:54

    Using the code below continuously adds 7px padding on the body element every time you open and close a modal.

    $('modalId').modal('hide');
    $('body').removeClass('modal-open');
    $('.modal-backdrop').remove();`
    

    For those who still use Bootstrap 3, here is a hack'ish workaround.

    $('#modalid').modal('hide');
    $('.modal-backdrop').hide();
    document.body.style.paddingRight = '0'
    document.getElementsByTagName("body")[0].style.overflowY = "auto";
    

提交回复
热议问题