jQuery pluggins, data() and namespace
<p>I am trying to better understand how to create jQuery plugins, and am basing my understanding off <a href="http://docs.jquery.com/Plugins/Authoring" rel="nofollow">http://docs.jquery.com/Plugins/Authoring</a>.  I am at the very end, and am confused on namespacing and data.</p>

<p><strong>First</strong> (see QUESTION 1 in the below code): the tutorial shows that the target (<code>$this</code>) and the tooltip is both stored in the object literal.  </p>

<ol>
<li>What is the benefit of storing these specific variables?   </li>
<li>If there was default values and custom options, would this be a good place to save the resulting settings object?</li>
</ol>

<p>Also, is there a reason they did <code>$(this).data('tooltip',{target:$this,tooltip:tooltip});</code>, instead of <code>$this.data('tooltip',{target:$this,tooltip:tooltip});</code>?</p>

<p><strong>Second</strong> (see QUESTION 2 in the below code): the tutorial shows how to destroy the plugin. I get <code>$this.removeData('tooltip');</code>, but what is the point of doing <code>data.tooltip.remove();</code>?</p>

<p>SOURCE: <a href="http://docs.jquery.com/Plugins/Authoring#Data" rel="nofollow">http://docs.jquery.com/Plugins/Authoring#Data</a></p>

<pre><code>(function( $ ){

  var methods = {
     init : function( options ) {

       return this.each(function(){

         var $this = $(this),
             data = $this.data('tooltip'),
             tooltip = $('&lt;div /&gt;', {
               text : $this.attr('title')
             });

         // If the plugin hasn't been initialized yet
         if ( ! data ) {

           /*
             Do more setup stuff here
           */

           //QUESTION 1
           $(this).data('tooltip', {
               target : $this,
               tooltip : tooltip
           });

         }
       });
     },
     destroy : function( ) {

       return this.each(function(){

         var $this = $(this),
             data = $this.data('tooltip');

         // Namespacing FTW
         $(window).unbind('.tooltip');

         QUESTION 2
         data.tooltip.remove();
         $this.removeData('tooltip');

       })

     },
     reposition : function( ) { // ... },
     show : function( ) { // ... },
     hide : function( ) { // ... },
     update : function( content ) { // ...}
  };

  $.fn.tooltip = function( method ) {

    if ( methods[method] ) {
      return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
    } else if ( typeof method === 'object' || ! method ) {
      return methods.init.apply( this, arguments );
    } else {
      $.error( 'Method ' +  method + ' does not exist on jQuery.tooltip' );
    }    

  };

})( jQuery );
</code></pre>
