O'Reilly logo

jQuery UI Cookbook by Adam Boduch

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building an observer widget

The typical approach to dealing with events triggered by jQuery UI widgets is to bind an event handler to that event name, passed directly into the constructor. It's the typical approach because it's easy to do, and it generally solves a specific problem we're having. For example, suppose that when a section of our accordion widget is expanded, we would like to update another DOM element. To do this, assign an event handler function to the activate event when the accordion is constructed.

This approach works well for small, single purpose jobs that apply to a single instance of a given widget. However, most meaningful applications have many widgets, all triggering their own events. The widget factory prefixes each event ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required