Skip to content
This repository has been archived by the owner. It is now read-only.
No description, website, or topics provided.
JavaScript CSS
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test add htc path for older IE and be sure to expire the live queries in t… Dec 18, 2013
.gitignore pulling in the mutated branch into master Apr 10, 2014
.jshintrc
ChangeLog.md pulling in the mutated branch into master Apr 10, 2014
Gruntfile.js pulling in the mutated branch into master Apr 10, 2014
LICENSE.txt
README.md
jquery.livequery.htc add in watching for attribute changes (class attribute only for now).… Aug 16, 2013
jquery.livequery.js pulling in the mutated branch into master Apr 10, 2014
jquery.livequery.min.js pulling in the mutated branch into master Apr 10, 2014
package.json

README.md

Live Query

This plugin is currently being rewritten. If you are looking for the old version, look at the 1.1.1 tag.

Live Query has been rewritten in version 2 to utilize DOM Mutation Observers or fallback to DOM Mutation Events. This covers a nice range of modern browsers and IE9 up. If you need to support less than IE9 then it will fallback to using behaviors to be notified of added and removed elements. This requires setting the $.livequery.htcPath so that it can load the included behavior file.

In the rewrite the event binding functionality has been removed since jQuery provides really nice event delegation. It now only supports passing in a matched and an optional unmatched function handler. These handlers are fired only when elements are added or removed from the DOM. This is slightly different from the original Live Query in that it would also monitor for slightly smaller changes that might make an element no longer match, such as a class name change.

Here is an example of how to use Live Query.

var $mylist = $('#mylist');
$mylist.livequery(
    'li', // the selector to match against
    function(elem) { // a matched function
        // this = elem = the li element just added to the DOM
    }, function(elem) { // an unmatched/expire function
        // this = elem = the li element just removed from the DOM or the live query was expired
    });

API

livequery

// selector: the selector to match against
// matchedFn: the function to execute when a new element is added to the DOM that matches
$(...).livequery( selector, matchedFn );

// selector: the selector to match against
// matchedFn: the function to execute when a new element is added to the DOM that matches
// unmatchedFn: the function to execute when a previously matched element is removed from the DOM
$(...).livequery( selector, matchedFn, unmatchFn );

expire

The first way will stop/expire all live queries associated with the selector.

// Stop/expire all live queries associated with the selector
$(...).expire( selector );

// Stop/expire all live queries associated with the selector and matchedFn
$(...).expire( selector, matchedFn );

// Stop/expire all live queries associated with the selector, matchedFn, and unmatchedFn
$(...).expire( selector, matchedFn, unmatchFn );

License

The Live Query plugin is licensed under the MIT License (LICENSE.txt).

Copyright (c) 2014 Brandon Aaron

You can’t perform that action at this time.