개인적으로 ajax 로 get 이나 post 를 할 때는 modal 형태의 progressive 를 사용한다.
modal 창이 뜬 상태에서 ajax 를 사용하게 되면 modal 이 중복되는 경우가 발생한다.
이 때 z-index 때문에 문제가 생기는 경우가 있는데 아래 링크 처럼 z-index 를 잘 조절하면 문제가 해결된다.
http://jsfiddle.net/likhi1/wtj6nacd/
핵심 코드는 아래와 같다.
$(document).on({ 'show.bs.modal': function() { 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); }, 'hidden.bs.modal': function() { if ($('.modal:visible').length > 0) { // restore the modal-open class to the body element, so that scrolling works // properly after de-stacking a modal. setTimeout(function() { $(document.body).addClass('modal-open'); }, 0); } } }, '.modal'); |