1
부트 스트랩 모달과 관련된 문제가 있습니다. 아래 코드를 구현했습니다. 무슨 일이 일어나고 있는지 모르겠지만 처음에는 "예"버튼을 누르면 잘 작동하지만 아니오 버튼을 클릭하면 그 다음에 예 버튼을 클릭하면 예 버튼 클릭 이벤트가 여러 번 해고됩니다. 나는 이런 일이 일어나는 이유를 전혀 모른다.부트 스트랩 모달 방법이 여러 번 실행됩니다.
$('#confirmationModal').modal('show');
$("#confirmationModal").on('shown.bs.modal', function() {
$('#confirmationModal').modal({
backdrop: 'static',
keyboard: false
}).one('click', '#yesbutton', function(e) {
$('#confirmationModal').modal('hide');
//Doing Ajax Stuff and alert data.
//Very important line.
//This is needed to prevent multiple firing of the yes button event.
$(this).off(event);
})
}); * * strong text * *
이해하기 쉽도록 스 니펫을 추가해주세요. modal ({ 배경 : '정적', 키보드) –
$ ("# confirmationModal"). ('shown.bs.modal', function (e) {e.peventDefault(); $ ('# confirmationModal' : }) 하나의 '클릭', '#yesbutton', function (e) { $ ('확인 모드') 모달 ('숨기기') // Doing Ajax Stuff 및 경고 데이터 .. // 매우 중요한 라인 이것은 예 버튼 이벤트의 여러 발사를 방지하기 위해 필요한 // $ (이) .OFF (이벤트) }) }); * * 강력한 텍스트 * * –
event.preventDefault() 사용 –