Chapter 8. Using the widget factory to build stateful plugins

 

This chapter covers

  • Creating widgets with the widget factory
  • The benefits of using the widget factory
  • Accessing a widget’s data and inner workings

Throughout this book, you’ve looked at the widgets jQuery UI provides and all the things you can do with them. Although the jQuery UI widgets let you do a lot, the widgets don’t cover all the UI controls you need to build modern web applications. Don’t worry—the most powerful part of jQuery isn’t its widgets, it’s the mechanism that all its widgets are built with: the widget factory.

The widget factory evolved from the early days of jQuery UI. Recall that the jQuery UI project started as a collection of popular plugins from a variety of authors, coding styles, and APIs. Over time, common patterns and best practices emerged. Implementations of these patterns gradually moved out of individual plugins and into a common base, which eventually became the widget factory. The widget factory itself is a jQuery plugin that builds jQuery plugins that adhere to these common conventions.

The widget factory is also a standalone component; you can use it independently of the jQuery UI library. In fact, the widget factory serves as the basis of all the jQuery Mobile widgets and numerous third-party jQuery plugins. By learning to use the widget factory, you’ll have the ability to build widgets that work anywhere that jQuery Core is available.

8.1. Building a widget

8.2. Customizing widgets with options, methods, and events

8.3. Enabling, disabling, and destroying widgets

8.4. Summary

sitemap