jQuery in Action

The Live Query Plugin
295
We've seen that Live Query automatically removes event listeners when an ele-
ment leaves the matched state and that we can establish a mismatch listener to do
whatever we want on such mismatch transitions. But what do we do when we want
to take a sledgehammer to the listeners?
9.3.4 Expiring Live Query listeners
In the same way that jQuery provides an
unbind()
command to undo the action
of
bind()
, Live Query provides its own means to undo the establishment of Live
Query event handlers and match/mismatch handlers--the
expire()
command,
which sports many parameter formats.
Function syntax: $.livequery.run
$.livequery.run()
Forces Live Query to perform a global evaluation of elements, triggering any appropriate
listeners. This is useful when changes to elements are made outside the control of
jQuery methods.
Parameters
none
Returns
Undefined.
Command syntax: expire
expire()
expire(event,listener)
expire(onmatch,onmismatch)
Removes listeners associated with the selector of the match set. The format without param-
eters removes all listeners associated with the selector. See the description of the parame-
ters below for how they affect this command.
Parameters
event
(String) Specifies that event listeners for the event type be unbound. If no lis-
tener is specified, all listeners for the event type are removed.
listener
(Function) When specified, only the specific listener is unbound from the
selector (for the specified event type).
onmatch
(Function) Specifies the match listener that's to be unbound from the selector.
mismatch
(Function) If present, specifies the mismatch listener to be unbound from
the selector.
Returns
The wrapped set.


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.