options.output?

options.output?

Hi,

I am dissecting a plugin, and I have a few questions about this bit of code:

  1. ;(function($) {
  2.    
  3.     $.fn.my_plug_xxxx = function(options) {
  4.        
  5.         var $foo = $(this);
  6.         var $output = $(options.output);
  7.         // ....
  8.        
  9.     };
  10.     // ....

The plugin is called like so:

  1. $.my_plug_xxxx($("#foo_div"), $("#output_div"), { // Options here ....

First, I have never seen a plugin work in this way (where the target div is the second object lookup in the plugin call.) Where in the docs could I read more about this functionality?

Second, if I opt to put my "output" option in the options object, how could I allow for both approaches? For example:

  1. // This way:
  2. $.my_plug_xxxx($("#foo_div"), $("#output_div"), { // Options here ....
  3. // Vs. this way:
  4. $("#foo_div").my_plug_xxxx({ output: '#output_div' // Other options here ....

In other words, how would the plugin account for both approaches when using a settings object? For example:

  1. ;(function($) { // Hide scope, no $ conflict.
  2.    
  3.     $.fn.my_plug_xxxx = function(options) {
  4.        
  5.         $settings = jQuery.extend({
  6.             output: ?????????????
  7.         }, options);
  8.        
  9.         var $foo = $(this);
  10.         // ....
  11.        
  12.     };
  13.     // ....

I hope my question makes sense.

TIA!

Cheers,
Micky