In general this is handled by having the widget be on a container element. A couple examples are selectable and sortable. We don't call .sortable() or .selectable() an elements that should be sorted and selected, but on containers of elements that can be sorted and selected. Does that help?
- Richard On Fri, Jun 5, 2009 at 9:35 AM, Aaron Barker <[email protected]> wrote: > > So in other words, there is no way to know how many are in the > collection without figuring that out, outside of the plugin. Right? > > So something like: > var numElems = $(".bob").length(); > $(".bob").plugin(); // then reference numElems in the plugin > > But then there is no way to know which number of that collection I am > on, without doing a comparison of the current element to each element > in the list (again needing to track that outside of the plugin). > > I'm guessing this isn't a widely used need then. > > Is there a better way to make a plugin that is sibling aware? > Basically I need to do something to the last element in the collection > (as part of the plugin, not part of the jQuery chain). That element > could be removed (again as part of the plugin), and then something > needs to be done to the new last element. > > Thanks for any input anyone can give. > > On Jun 5, 6:06 am, "Richard D. Worth" <[email protected]> wrote: > > Seehttp://wiki.jqueryui.com/Widget-factory > > > > "If you select multiple elements and call .myWidget() on the collection, > a > > separate plugin instance will be instantiated for each element. In other > > words, this.element will always contain exactly one element." > > > > - Richard > > > > On Thu, Jun 4, 2009 at 12:35 PM, Aaron Barker <[email protected]> > wrote: > > > > > So I'm trying to use the widget factory for a plugin I am writing, but > > > need access to two things that I can't find. > > > 1) A count of how many items are in the collection > > > 2) What item I am on (number). > > > > > How would I find these items? > > > In a regular jQuery plugin I can get the number before I go into the > > > "return this.each(function(i){..." and then use the "i" in that > > > example to get the current number. > > > > > Are these available when iniside the _init of the widget factory? > > > > > Thanks > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
