[jQuery] Plugin Authoring
Hi plugin writers,
I'd like to point to a small change I made recently to the jQuery
Plugins Authoring article, for all those who take others code as
reference. The "reference code" to define defaults and parse options now
looks like this:
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 :-)
Credits for the options || {} idea go to Franck Marcia.
Regards
Jörn
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/