The jQuery UI widget pattern buils on top of the jQuery plugin pattern. It codifies some general best practices/conventions, as well as adds some new pieces. With the widget pattern you get
- init - defaults - options - state - methods - enable/disable - event handling - destroy (undo/cleanup) Many of these are handled currently by plugin authors, sometimes in different ways. So generally a widget will be more complex than a plugin, but it's also a plugin itself. And everything it does could be written as just a plugin. Creating it as a widget means you have some lower-level shared abstraction to take care of init, get/set options, exposing methods, events, etc. If you're just going to call it once with an argument or two, better off with a plugin. If you're creating something the user will see, touch, feel, interact with, a widget may be a good fit. - Richard On Wed, Nov 12, 2008 at 1:19 PM, Bramus! <[EMAIL PROTECTED]> wrote: > > (about to do a presentation on UI Widgets at Barcamp Ghent 2 and want > to have some input on this, just to make sure that I'm not spreading > out some bollocks into the world ;-)) > > I was wondering: if I were to write a new functionality to use with > jQuery, when exactly would I choose to write a plugin and when to > write a widget? > > Take a starrater or a progressbar for example: one could code it as a > widget, but one could code it as a plugin too. What are the advantages > of using either one of the methods? > > Thanks, > Bram. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery UI" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/jquery-ui?hl=en -~----------~----~----~----~------~----~------~--~---
