I believe this question relates to this: How does the init function work in plugins? and whoever can answer this can probably answer that.
I noticed something about jQuery, if I call my plugin like:
$('.view_title_images').prodigal({width: 500});
$('.glglg').prodigal({ width: 600 });
And then, in my init
function I extend with:
options = $.extend({}, options, opts);
and add that to each element: $(this).data('prodigal', options)
in the selector. I get the correct width
value for each element (500
for one and 600
for the other) later on when I call another function, open
on the click
of the element.
However if I do:
options = $.extend(options, opts);
For both selectors, despite being called separately, I get 600
. I test this by doing, in my open
function:
console.log($(this).data('prodigal'));
I know that not extending to an empty object will override the object for that selector/global object but why is this happening on the data
of each selector?