diTii.com Digital News Hub

Sign up with your email address to be the first to know about latest news and more.

I agree to have my personal information transfered to MailChimp (more information)


jQuery: Live Query Plugin

Brandon Aaron has written a new jQuery plugin Live Query. Live Query, previously called Behavior, utilizes the power of jQuery selectors by binding events or firing callbacks for matched elements auto-magically, even after the page has been loaded and the DOM updated.

For example you could use the following code to bind a click event to all A tags, even any A tags you might add via AJAX or a script.

.livequery('click', function(event) {
return false;

Live Query also has the ability to fire a callback function when it matches a new element and another callback function for when an element is no longer matched. This provides ultimate flexibility and untold use-cases. For example the following code uses a function based Live Query to implement the jQuery hover helper method and remove it when the element is no longer matched.

.hover(function() {
}, function() {
}, function() {

It may also be included into the core of jQuery v1.2 with more information found in the jQuery roadmap.

Live Query can be downloaded from the Live Query project page or look at the demos in action. The Live Query documentation is a work in progress but the API is fully documented.

Live Query, jQuery, Plugins

Share This Story, Choose Your Platform!

Do NOT follow this link or you will be banned from the site!