0

I have been trying to follow the tips in this topic Bootstrap: Open Another Modal in Modal but I don't seem to be getting any results. I have two modals, the main one with id testModal and another one that opens when a link is clicked, with id salesModal.

$(document).on('show.bs.modal', '#salesModal', function (event) {
    //alert('Test Modal');
         var zIndex = 1040 + (10 * $('.modal:visible').length);
         $(this).css('z-index', zIndex);
         setTimeout(function() {
             $('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
         }, 0);
    });

but the salesModal still opens behind the testModal. Which part am I missing and doing wrong? As you can see, I had a debug alert in there to ensure that I am reacting at the right time, ie. when salesModal opens and that works fine.

artlemaks
  • 147
  • 3
  • 14

1 Answers1

0

Layering Modals in Bootstrap can be strange but here is a quick bootply of how I normally do it. When the HTML is properly nested it should behave like below: https://www.bootply.com/zg3CRlEMkV#

However when using the data-dismiss="modal" This will close all of the open modals. So you need to close the nested one via a JS call with an on click.