Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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



Thank you Alex, I'll change it tomorrow!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: