jQuery in Action
The jQuery Event Model
107
Note that the
trigger()
command (as well as the convenience commands that
we'll introduce in a moment) does not cause an event to be triggered and to prop-
agate through the
agate through the
DOM
hierarchy. As there's no dependable cross-browser means
to generate an event, jQuery calls the handlers as normal functions.
Each handler called is passed a minimally populated instance of
Event
.
Because there's no event, properties that report values, such as the location of a
mouse event, have no value. The
mouse event, have no value. The
target
property is set to reference the element
of the matched set to which the handler was bound.
Also because there's no event, no event propagation takes place. The handlers
bound to the matched elements will be called, but no handlers on the ancestors of
those elements will be invoked. Remember, these commands are convenient ways
to call an event handler, not to try and emulate an event.
those elements will be invoked. Remember, these commands are convenient ways
to call an event handler, not to try and emulate an event.
In addition to the
trigger()
command, jQuery provides convenience com-
mands for most of the event types. The syntax for all these commands is exactly
the same except for the command name, and that syntax is described as follows:
the same except for the command name, and that syntax is described as follows:
In addition to binding, unbinding, and triggering event handlers, jQuery offers
high-level functions that further make dealing with events on our pages as easy
as possible.
high-level functions that further make dealing with events on our pages as easy
as possible.
4.2.6 Other event-related commands
There are often interaction styles that are commonly applied to pages in Rich
Internet Applications and are implemented using combinations of behaviors.
Internet Applications and are implemented using combinations of behaviors.
Command syntax: eventName
eventName()
Invokes any event handlers established for the named event type for all matched elements.
The supported commands are as follows:
The supported commands are as follows:
blur
click
focus
select
submit
Parameters
none
Returns
The wrapped set.
The wrapped set.