jQuery in Action
84
CHAPTER 4
Events are where it happens!
4.1 Understanding the browser event models
Long before anyone considered standardizing how browsers would handle
events, Netscape Communications Corporation introduced an event-handling
model in its Netscape Navigator browser; all modern browsers still support this
model, which is probably the best understood and most employed by the majority
of page authors.
events, Netscape Communications Corporation introduced an event-handling
model in its Netscape Navigator browser; all modern browsers still support this
model, which is probably the best understood and most employed by the majority
of page authors.
This model is known by a few names. You may have heard it termed the
Netscape Event Model, the Basic Event Model, or even the rather vague Browser
Event Model; but most people have come to call it the
Event Model; but most people have come to call it the
DOM
Level 0 Event Model.
NOTE
The term
DOM
Level is used to indicate what level of requirements an
implementation of the
W3C DOM
Specification meets. There isn't a
DOM
Level 0, but that term is used to informally describe what was imple-
mented prior to the
mented prior to the
DOM
Level 1.
JavaScript you need to know!
One of the great benefits that jQuery brings to web applications is the ability to
implement a great deal of scripting-enabled behavior without having to write a
whole lot of script ourselves. jQuery handles the nuts-and-bolts details so that we
can concentrate on the job of making our applications do what it is that our appli-
cations need to do!
implement a great deal of scripting-enabled behavior without having to write a
whole lot of script ourselves. jQuery handles the nuts-and-bolts details so that we
can concentrate on the job of making our applications do what it is that our appli-
cations need to do!
Up to this point, the ride has been almost free. You only needed rudimentary Java-
Script skills to code and understand the jQuery examples we introduced in the
previous chapters; in this chapter and the chapters that follow, you must under-
stand a handful of fundamental JavaScript concepts to make effective use of the
jQuery library.
Script skills to code and understand the jQuery examples we introduced in the
previous chapters; in this chapter and the chapters that follow, you must under-
stand a handful of fundamental JavaScript concepts to make effective use of the
jQuery library.
Depending on your background, you may already be familiar with these concepts,
but some page authors can write a lot of JavaScript without a firm grasp on exactly
what's going on under the covers--the flexibility of JavaScript makes such a situa-
tion possible. Before we proceed, it's time to make sure that you've wrapped your
head around these core concepts.
but some page authors can write a lot of JavaScript without a firm grasp on exactly
what's going on under the covers--the flexibility of JavaScript makes such a situa-
tion possible. Before we proceed, it's time to make sure that you've wrapped your
head around these core concepts.
If you're already comfortable with the workings of the JavaScript Object and Func-
tion
tion
classes and have a good handle on concepts like function contexts and clo-
sures, you may want to continue reading this and the upcoming chapters. If these
concepts are unfamiliar or hazy, we strongly urge you to turn to appendix A to help
you get up to speed on these necessary concepts.
concepts are unfamiliar or hazy, we strongly urge you to turn to appendix A to help
you get up to speed on these necessary concepts.