Some questions regarding the widget factory (_init vs. _create, $.data, multiple widget instances)

Some questions regarding the widget factory (_init vs. _create, $.data, multiple widget instances)

One of the best parts of jQuery UI is IMO the widget factory. Some time ago I created a similar construct, which shared many, if not all, of the widget factory's goals. The result is also strikingly similar. Now I'd like to swap my home-grown solution for UI's widget factory, and I started digging into the code of the new 1.8b1 release.


Although most of it is pretty clear, I have a couple of questions/concerns:


(1) What's the difference between a widget's _init() and _create() methods? Both of them are still being used in ui.dialog for instance, yet I don't understand why.


(2) The coding standards at the wiki (http://wiki.jqueryui.com/Coding-standards state: "don't save any data on the element other than the plugin instance." So how am I supposed to persist state of individual elements that are contained by the element on which the widget is instantiated? ui.selectable is doing it by means of... saving data on the selectable items. It even saves the data directly on the element (without prepending it with widget name or whatever). That's scary with regard to potential name clashes.


(3) Which brings me to my last concern. Am i correct that a DOM element can only have one widget instance of the same name (regardless of namespace) at the same time? So for any kind of functionality that can be used in parallel with some other functionality I should define a separate widget 'class'? Even if the two functionalities share 95% of their business logic? Or should we use inheritance/mixins in situations like these?


I'd love to hear your view on these issues. Thanks!