Bootstrap 모달 안에 모달 띄울 때 배경 처리: z-index 조정 코드

 
<script>
$(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'));
});
  </script>

bootstrap에서 모달 안쪽에 모달을 띄울경우 
새로운 모달의 아래 배경은 까맣게 처리가 안되는 경우가 있다. 

그럴경우 위 코드를 넣어보자.