title: jQuery UI widget mouse event get at the Widget state?
body: <p>With the jQuery UI Widget factory pattern (1.8), I'm having trouble finding the widget object itself while in a mouse event:</p>
  
  <pre><code>$.widget('foo.myWidget', {
    _create: function() {
      var $container = this.element.wrap('&lt;div class="ui-widget" /&gt;').parent(); // Create a widget container
      $container.append('&lt;div class="myWidgetControl" /&gt;'); // Add some clickable thing
      $container.find('.myWidgetControl').on('mouseup.myWidget', this._handleClick); // Watch the mouse event
    },
    options: { // Widget factory options object
      secretKey: 'foobar'
    },
    _handleClick: function(e) {
      // User clicked on ".myWidgetControl"
      // this == DOM element .myWidgetControl
      // e == the jQuery event object
  
      // I need to get options.secretKey; how do I find it?!?
    }
  });
  </code></pre>
  
  <p>In the above example, how do I get the "secretKey" option parameter? Given that there might be multiple instances of this widget on the page, how do I get the proper instance for the control element the user clicked?</p>
  
  <p>The 'widget' method <a href="http://jqueryui.com/docs/Upgrade_Guide#New_Widget_Method" rel="nofollow">added in 1.8</a> looks like it might be a solution, but it requires knowing what element the user originally applied the widget to:</p>
  
  <pre><code>$("#myDiv").myWidget("widget");
  </code></pre>
  
  <p>In that case, how do you find out what the user originally set as the selector for this instance of the widget ("#myDiv" in the example)?</p>