부트 스트랩 (버전 2.3.1)을 사용 중이며 Ajax를 사용하여 모달 창을로드하고 있습니다. 모달 창을 닫을 때 DOM에서 모달 창을 제거하는 방법이 있습니까?Ajax를 사용하여 트위터 부트 스트랩을 사용하여 모달 창을로드/언로드
$('[data-toggle="modal"]').click(function(e) {
e.preventDefault();
var url = $(this).attr('href');
if (url.indexOf('#') == 0) {
$(url).modal('open');
} else {
$.get(url, function(data) {
$(data).modal();
}).success(function() {
console.log('success');
// I tried this below but didn't work
// $('#modalClose).on('click',function(){
// $('#myModalWindow').remove();
// });
});
}
});
내 버튼 : 내 모달 창에서
<a href="path/to/modal.html" data-target="#" data-toggle="modal">Launch modal</a>
, 나는 닫기 버튼이있다.
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
그러나 모달을 닫으면 HTML이 DOM에 남아 있으며 모달을 다시로드하면 HTML이 다시 출력됩니다. 모달 창을 닫을 때 DOM에서 모달 창을 제거하는 방법이 있습니까?
문제점의 해결책을 찾으셨습니까? – MattSull