title: how to let jQuery plugin function return intrinsic value
body: <p>I am using the following pattern to write a jquery plugin, and I want the <code>bar</code> function to return intrinsic value, but it seems always to return <code>$(this)</code> instead.<br>
  Anything wrong with the code?</p>
  
  <pre><code>(function($){
  
      var Foo = function(elements, options){
      ... ...
      }
  
  
      Foo.prototype = {
  
          constructor: Foo,
  
          bar: function(){
              var value = ...        
              // do something here
              return value;
          },
  
      }
  
      $.fn.foo = function (option, kwargs){  
          return this.each(function(){ 
              var $this = $(this),
                  data = $this.data('foo'),
                  options = typeof option == 'object' &amp;&amp; option
  
              if (!data) $this.data('foo', (data = new Foo(this, options)))
              if (typeof option == 'string') return data[option](kwargs)
          })            
      }
  
  
  })(jQuery)
  </code></pre>