John Resig schrieb:
>> 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

This is cool, but as plugin developer I cannot assume the latest jQuery 
SVN version, right?

-- Klaus

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to