The object passed to $.widget as the second argument ends up as the widget's prototype. So anything non-instance specific can go there.
Jörn On Sun, Aug 30, 2009 at 7:46 PM, Kevin Dalman<[email protected]> wrote: > > I'm working on converting a plug-in to UI Widget format, and am > confused about how the factory handles instances and prototypes... > > In a normal Javascript object that will be instantiated, I put only > the instance-specific data in the base object. I create all methods as > prototypes so that they are *not* instantiated. I have looked at > numerous widgets for examples of prototyping, but have not seen any > pattern that makes sense to me. > > So my question is, should widgets be created using prototypes? Or is > *everything* a prototype? For example... > > $.widget("ui.dialog", { > _init: function() { ... } > , destroy: function() { ... } > , close: function() { ... } > , open: function() { ... } > }); > > Are methods declared like this 'instantiated', or are they prototypes? > > Only rarely do I see methods 'specifically' added to the prototype, > like... > > $.extend($.ui.tabs.prototype, { > rotation: null, > rotate: function(ms, continuing) { > ... > }); > > Any guidance would be appreciated. > > /Kevin > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
