Chapter 3. Event Listeners and Pub/Sub Communication
Base provides extremely useful and versatile utilities for communication between JavaScript objects, DOM nodes, and any combination thereof. This chapter introduces these constructs as well as guidelines for when each of them might be most appropriate to employ. As writing portable code that involves DOM events necessarily depends on a standardized event model, you'll also learn a little bit about how Dojo works behind the scenes to smooth out some of the inconsistencies amongst mouse and keyboard events. The chapter concludes with a discussion of publish/subscribe communication, which provides a great vehicle for realizing an architecture with loosely coupled components.
Event and Keyboard Normalization
Some of the oldest code in the toolkit was written to smooth out inconsistencies with the underlying event model amongst different browsers. This section provides a brief overview of the events that you can count on being normalized when you use Dojo to develop an application. The basis of standardization is the W3C model.
Mouse and Keyboard Event Normalization
The dojo.connect machinery
that you'll read about in the following section often involves a
mouse event on a particular DOM node. Whenever you use Dojo, you can
rest assured that the following mouse and keyboard events are
supported in accordance with the W3C standard:
onclick |
onmousedown |
onmouseup |
onmouseover |
onmouseout |
onmousemove |
onkeydown |
onkeyup |
onkeypress |
Tip
In addition to supporting ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access