2016-10-04 3 views
0

이벤트 처리를 추가해야합니다 (tabs 초기화 후). 나는이탭 만들기 이벤트가 실행되지 않습니다.

$("#payment-popup").tabs({ 
    heightStyle: "content", 
    activate: function(event ,ui){ 
     $(this).find($(".ui-tabs-nav")).toggleClass("hidden2"); 
     $("#payment-popup-menu-button").toggleClass("hidden2"); 

    } 

}); 

...

(function($){ 
    $("#payment-popup").on("tabsactivate", function(event, ui) {alert('alert 1')}); 
    $("#payment-popup").on("tabscreate", function(event, ui) {alert('create fire')}); 
})(jQuery); 

하지만 경고 않습니다. 뭐가 잘못 되었 니?

나는 순서로 입력 한 경우이 코드가 작동 기대
+0

은 (는 요소가로드 된 것을 확신 할 수있는 방법이기 때문에 문서 준비 리스너를 추가 한) 안녕하세요 @ 올렉산드르,이 탭들은 어디에서 왔습니까? jQuery-ui에서 온 것입니까? –

+1

jQuery를 사용하여 사용자 지정 이벤트를 추가/트리거하는 방법을 찾으려면 다음을 참조하십시오. http://api.jquery.com/trigger/ –

+0

@TimothyGroote이 매뉴얼 http : // api를 따른다. .jqueryui.com/tabs/# event-create 이렇게하면 'tabs' 플러그인에 의해 이미 트리거되어야한다고 가정합니다. –

답변

0

:

$(document).ready(function(){ 

     //no need to look up the same element twice. 
     var paymentPopupElement = $("#payment-popup") 

     paymentPopupElement.on("tabscreate", function(event, ui) {alert("create fire")}); 

     paymentPopupElement.tabs({ 
     heightStyle: "content", 
     activate: function(event ,ui) 
     { 
      $(this).find($(".ui-tabs-nav")).toggleClass("hidden2"); 
      $("#payment-popup-menu-button").toggleClass("hidden2"); 

     } 
     }); 

}); 
관련 문제