2012-09-26 4 views
0

두 가지 기능을 버그 처리하고 이벤트를 발생시키기위한 코드가 있습니다. 그러나 어떤 이유로 이벤트가 실행되지 않는 것 같습니다. 예상대로 콘솔에 로그온하지만 이벤트가 실행되지 않습니다.이벤트가 실행되지 않습니다.

//Show backstage event 
(function($, oldRem){ 
    backstage.show = function(){ 
     console.log("yup, I'm the right one"); 
     var resp = oldRem.apply(this, arguments); 
     $("#backstageArea").trigger("showBackstage"); 
     return(resp); 
    }; 
})(jQuery, backstage.show); 
//Hide backstage event 
(function($, oldRem){ 
    backstage.hide = function(){ 
     console.log("And so am I."); 
     var resp = oldRem.apply(this, arguments); 
     if(anim && config.chkAnimate) {setTimeout('jQuery("#backstageArea").trigger("hideBackstage")', config.animDuration);} 
     else {$("#backstageArea").trigger("hideBackstage");} 
     return(resp); 
    }; 
})(jQuery, backstage.hide); 

//Resize never logs its console message. 
jQuery.bind("hideBackstage", function(){topbar.resize();}); 
jQuery.bind("showBackstage", function(){topbar.resize();}); 
+0

'jQuery ("# backstageArea")를 시도해 봤나?'jQuery.bind (...'?) 대신 bind (...'? – nnnnnn

+0

그랬습니다. 답변에 넣을 수 있습니까? –

+1

아직 자바 스크립트 및 기타 오류를 디버깅하는 데 유용한 도구 인 [** Firebug **] (https://getfirebug.com/)를 확인하십시오. –

답변

3

당신은에 bind에 어떤 요소 (들)를 지정, 그래서 시도 할 필요가 : 당신이 jQuery를 버전을 사용하는 경우

jQuery("#backstageArea").bind(... 

대신

jQuery.bind(... 

을 (그리고 1.7+ .on() method으로 전환하고 싶을 수도 있습니다.이 목적으로는 같은 효과가 있지만 v1.7에서 권장되는 방법입니다.)