Publishing Custom Events in JavaScript

by admin on June 22, 2006

Dustin Diaz is at it again, this time discussing “custom events” and how to create and use them. A custom event is an event that you define (e.g. onDrool vs. onBlur).

Dustin uses the Yahoo! UI event util library to show off how to play with events:

// Define Event
var onMenuCollapse = new YAHOO.util.CustomEvent(‘menu collapse’);// Define Event
onMenuCollapse.fire();

// Subscribe to an event
onMenuCollapse.subscribe(swapColors);

To see it in action you can check out a couple of examples:

YUI Custom Events

Leave a Comment

Previous post:

Next post: