title: How to destroy a jQuery UI widgets from within it's prototype
body: <p>I've gotten on board to using the Widget Factory for creating plugins. However I can't seem to find a way to destroy the plugin from within.</p>
  
  <p>In all the examples and tutorials I've found so far they destroy the plugin from the DOM. Which is all good and well but I would also like to be able to destroy the plugin from within my prototype.</p>
  
  <p>Say for example the plugin is invoked with incorrect parameters or a incorrect element or after some time it does not validate. I would like to be able to call this.destroy() afterwards and destroy the plugin. When i call this.destroy() it does call the $.Widget.prototype.destroy() and my subsequent _destroy() method but the instance is still on the DOM element. Only when calling $(el).pluginName('destroy') does it get truly destroyed.</p>
  
  <p>Quick example here</p>
  
  <p>Say we have some html</p>
  
  <pre><code>&lt;p&gt;Lorem ipsum&lt;/p&gt;
  </code></pre>
  
  <p>and our jQuery UI widget, which aims to destroy it as soon as it's created</p>
  
  <pre><code>$.widget('ns.test', {
      _create: function() {
          this.destroy();
      },
  
      _destroy: function() {}
  });
  </code></pre>
  
  <p>and we invoke the pluging so</p>
  
  <pre><code>$('p').test();
  </code></pre>
  
  <p>I would expect that the instance would not be set on the $('p') but it is</p>
  
  <pre><code>$('p').data();
  &gt;&gt; Object {ns-test: $.widget.$.(anonymous function).(anonymous function)}
  </code></pre>
  
  <p>Only when calling the method from the DOM it gets destroyed</p>
  
  <pre><code>$('p').test('destroy');
  &gt;&gt; Object {}
  </code></pre>
  
  <p>Any thoughts anyone?</p>