Hi,
I am dissecting a plugin, and I have a few questions about this bit of code:
- ;(function($) {
-
- $.fn.my_plug_xxxx = function(options) {
-
- var $foo = $(this);
- var $output = $(options.output);
- // ....
-
- };
- // ....
The plugin is called like so:
- $.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:
- // This way:
- $.my_plug_xxxx($("#foo_div"), $("#output_div"), { // Options here ....
- // Vs. this way:
- $("#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:
- ;(function($) { // Hide scope, no $ conflict.
-
- $.fn.my_plug_xxxx = function(options) {
-
- $settings = jQuery.extend({
- output: ?????????????
- }, options);
-
- var $foo = $(this);
- // ....
-
- };
- // ....
I hope my question makes sense.
TIA!
Cheers,
Micky