Friday, July 28, 2023

Bootstrap 5 Multiple Modal Overlay | How to use multiple modal in bootstrap?

Let me explain my problem, I am using bootstrap modal for my project. That is fine but I get stucked when another modal open over first modal. To solve this problem I added below javascript code to my project and it get solved.
$(document).on('show.bs.modal', '.modal', function() {
    const zIndex = 1040 + 10 * $('.modal:visible').length;
    $(this).css('z-index', zIndex);
    setTimeout(() => $('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack'));
});
Now my modals are looking like below:

No comments:

Post a Comment