목차
접기
728x90
반응형
On the page, a datepicker is used in the element using the modal.
There was a problem that the modal was closed every time I clicked on a date on the datepicker's calendar.
$('#test').datepicker({
format: "yyyy-mm-dd",
autoclose: true
});
The above code is an existing code with datepicker set.
Below is a code to prevent the modal from closing when the date is selected with the datepicker in the modal.
$('#test').datepicker({
format: "yyyy-mm-dd",
autoclose: true
}).on('hide', function(e){
e.stopPropagation();
});
Below is a function for generating an event before the modal closes.
$('#test_modal').on('hide.bs.modal', function (e) {
alert('Notification before the modal closes!!');
e.preventDefault();
});
Below, let's develop it by referring to the event type that can be used for events before and after opening and closing the modal.
event type | descr |
show.bs.modal | It is an event that runs immediately when the modal opens. |
shown.bs.modal | It is an event that runs after the modal opens. |
hide.bs.modal | It is an event that runs immediately when the modal closes. |
hidden.bs.modal | This is an event that runs after the modal closes. |
728x90
반응형
LIST
'javascript' 카테고리의 다른 글
[ jQuery ] 특정 문자열을 포함하고 있는 요소를 찾는 방법 (0) | 2022.01.19 |
---|---|
for문 사용법 (0) | 2022.01.15 |
[ jquery ] datepicker 라이브러리로 년, 월말 출력되도록 하는 방법 (0) | 2021.09.08 |
[ jquery ] datatable 사용법!!! 너비 설정하는 방법 (0) | 2021.09.02 |
[ jQuery ] 같은 부모 아래 다른 자식 요소 찾기 / 형제자매 요소 select .siblings() / (0) | 2021.09.01 |