SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 121 | Next

Dan Wellman

"Learning the Yahoo! User Interface library"


The event object and how it is accessed has also been refined so that it can be
obtained in the same way regardless of the browser to a certain extent. You don't
need to add separate code routines that look for the object under window.event as
well as an argument of your handler because the YUI always passes the event object
to your event handler, making it available whenever you need to access it.
Chapter 3
[ 93 ]
Evolving Event Handlers
In the early event models event handlers were attached directly to their HTML
elements as attributes. For example, a click handler would go into the HTML for the
link as an onclick attribute:

Once the W3C provided the standardized event model, handlers could be
implemented directly in the accompanying script without cluttering the HTML
mark up that defined the page:
document.getElementById('someElement').onclick = someFunction;
The YUI Event utility takes the direct implementation method one step further,
giving you a standard method of attaching certain listeners to selected elements:
YAHOO.util.Event.addListener(someElement, "someEvent",
someHandler);
The Event utility provides an extensive range of methods, all of them equally as
useful in their own way as the addListener() method and all designed to make
coding an event-driven application quicker and easier.


Pages:
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133