3 ms·
When handling options, I quite like this pattern: var settings = $.extend({ dragable: true, clickable: true, ontext: 'ON', offtext:
by alexyoung 14y ago
When handling options, I quite like this pattern:
var settings = $.extend({
dragable: true,
clickable: true,
ontext: 'ON',
offtext: 'OFF',
on: true,
animtime: 300
}, opts);
The $.extend method still returns a suitable object even if `opts` is undefined.
You also might want to `return this.each` so calls can be chained.
All of this is covered here: http://docs.jquery.com/Plugins/Authoring http://docs.jquery.com/Plugins/Authoring
- simontabor 14y agoThank you Alex, I'll change it tomorrow!