Can someone concisely explain the differences between jQuery plugins and jQuery UI widgets? What are the conceptual differences? Why would I choose one over the other and what pros and cons are there for each. What are the differences in the intention and concept for each?
I've written both, but I'm not clear on the nitty gritty differentiations. I want to make sure I'm choosing appropriately in each case.
Thanks!
Widgets are part of the jQuery UI library, where plugins aren't. Also, the Widgets have a visual component for the GUI, whereas plug-ins don't necessarily (although some do).
jQuery Widgets are better if we need to develop a UI interface that does not need to interact with other functionalities. It is best used if we need to display different content using the same widget as we can optimize using _create and _init.
Plugins are best when we need to implement certain functions in a pipeline fashion one after another.
$(".selector").plugin1().plugin2();
精彩评论