title: jQuery Plugin Authoring - Set different options for different elements
body: <p>I have created a jQuery plugin that works great with the exception of being able to call the plugin on different objects and each object retaining the options it was given.  The problem is that if I call the plugin on one object, say:</p>
  
  <pre><code>$('#myDiv1').myPlugin({
      option1: 'some text',
      option2: true,
      option3: 'another option value'
  });
  </code></pre>
  
  <p>then call the plugin again on another object, say:</p>
  
  <pre><code>$('#myDiv2').myPlugin({
      option1: 'different text',
      option2: false,
      option3: 'value for myDiv2'
  });
  </code></pre>
  
  <p>Then if I go back and try to do something with #myDiv1 that needs its original options to still be intact, ie: </p>
  
  <pre><code>$('#myDiv1').myPlugin.update();
  </code></pre>
  
  <p>it won't have it's original options, but they will be overridden by the options for #myDiv2.  What's the proper way to do this so that each object will retain the original options given to it?  (And here's some example code of what I'm doing in the plugin)</p>
  
  <pre><code>(function($) {
  $.fn.myPlugin = function(options) {
  
      // build main options before element iteration
      var opts = $.extend({}, $.fn.myPlugin.defaults, options);
  
      _option1 = opts.option1;
      _option2 = opts.option2;
      _option3 = opts.option3;
  
      // iterate all matched elements
      return this.each(function() {
          callPluginFunctions( this, opts );
      });
  
  };
  
      ....code continued....
  </code></pre>
  
  <p>I realize this is some kind of scope creep or something.  So, how do I get my options to stay attached and remain in the scope of the original object (ie #myDiv1) that they were given to.</p>
  
  <p><strong>EDIT:</strong> In doing some research I see that you can store data to an object using jQuery's .data function, and the docs say jQuery UI uses it extensively.  Would the proper thing to do here be store the options on the object using .data, then when referenced later use the options stored in .data ???</p>