728x90

모달 open시 처리

$('#cust-list').on('show.bs.modal', function () {    ~~~~    });

jQuery click 이벤트 중복 발생 문제

off()를 이용한다.

1) 모든 이벤트 제거
$("#id").off().on('click', function() {}

2) click 이벤트만 제거
$("#id").off("click").on('click', function() {}
unbind 후 bind하기

//클릭이벤트 unbind
$("#test-button").unbind("click");
//클릭이벤트 bind
$("#test-button").bind("click",function(){
    alert("click event");
});

2) unbind, bind 한 번에
//클릭이벤트 unbind & bind
$("#test-button").unbind("click").bind("click",function(){
    alert("click event");
});
3. .stopPropagation()
현재 이벤트가 부모에게 전파되지 않도록 중지

4. .preventDefault()
현재 이벤트 기본 동작 중지

5. .stopImmediatepropagation()
현재 이벤트가 부모와 현재 레벨에 걸린 다른 이벤트도 동작하지 않도록 중지
동일한 하나의 버튼에 이벤트가 여러 개 걸려 있을 때, 
이 메소드를 쓴 이벤트만 발생하고 나머지 이벤트는 발생하지 않는 것.

 

728x90

+ Recent posts