Define function inside the the module in javascript
<p>I tried to define a function attachPicker can be called like:</p>

<pre><code>(function(){
  $.fn.tagPicker = function(source){
    this.attachPicker();
  }
})(jQuery);
</code></pre>

<p>I tried:</p>

<pre><code>(function(){
    $.fn.tagPicker = function(source){
      this.attachPicker();
      //define attachPicker
      $.fn.attachPicker = function(){
        //code here
      }
    }
 })(jQuery);


(function(){
      $.fn.tagPicker = function(source){
          this.attachPicker();
          //define attachPicker
          this.attachPicker = function(){
            //code here
          }
      }
})(jQuery);
</code></pre>

<p>Both threw out </p>

<pre><code>Uncaught TypeError: Object [object Object] has no method 'attachPicker' 
</code></pre>

<p>If I did</p>

<pre><code>(function(){
      $.fn.tagPicker = function(source){
        this.attachPicker();
      }
      $.fn.attachPicker() = function(){ //codes here };
})(jQuery);
</code></pre>

<p>It worked. But I want to define attachPicker inside tagPicker so that it can access the source. Anyone can explain why the ones I tried didn't work and give me any suggestions? Of course I knew I can pass source as argument if defining attachPicker outside.
Thanks in advance!</p>
