> jQuery.fn.pluginMethod = function(options) {
> var settings = $.extend({
> stuff: [5, 3, 6, 1],
> name: "pete",
> speed: 5
> }, options || {});
> // other plugin code
> };
>
> So far this is the shortest way to write that particular snippet, and
> I'd like to see it in your plugins :-)
And this is even shorter, plus there's one less variable being defined:
jQuery.fn.pluginMethod = function(settings) {
settings = jQuery.extend({
// stuff....
}, settings);
};
As noted previously - make sure that you use jQuery.extend() instead
of $.extend().
> Credits for the options || {} idea go to Franck Marcia.
Having to do that is no longer needed in SVN - I added a catch to see
if a null or undefined value was being passed in and handled it
gracefully.
--John
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/