2010-12-31 6 views
1

I가 removeSomething을 (통화 할) (라인 9 참조)은 내부 :jQuery 플러그인 호출 내부 함수

(function($){ 
     $.fn.extend({ 
     Engine: function(options) { 
      var defaults = { 
      ... 
      }; 
      var options = $.extend(defaults, options); 

      removeSomething(); 

      //----------------------------------------------------------------------- 
      //Public Functions ------------------------------------------------------ 
      //----------------------------------------------------------------------- 

      this.removeSomething = function() { 
      ... 
      }; 
     } 
     }); 
    })(jQuery); 

하지만 콘솔 출력 removeSomething 부르면 removeSomething가 아니라고 :

JS 코드는 함수,이 함수를 어떻게 호출해야합니까? 이 기능은 내부 및 외부에서 사용할 수 있어야합니다.

도움 주셔서 감사합니다.

var 또는 다른 = function() {... 구문을 선언 할 때는

답변

5

이, 함수가이 경우에, 당신이 그것을 사용 전에 정의하고, 정의 된 그러나 호출 할 필요가 :

this.removeSomething = function() { 
    ... 
}; 
//*then* 
this.removeSomething();