Jun
29

Live Query Plugin: Solution of your problems in jQuery

Author ZeeShaN    Category JQuery, Web Development     Tags

Some one asked me about the solution of binding events to dynamically generated elements. And one name came in my mind that is LiveQuery. If you have used jQuery very well and worked on some dynamic created content using jQuery Ajax, then you must faced links binding problem to these new elements.

For example:

If you are performing some delete action on click of any element using its ID.

$('a#someID').click(function(){
// your code
});
// or something like
$('a#someID').mouseenter(function(){
// your code
});
// or something like
$('a#someID').focus(function(){
// your code
});

And if there are some dynamically generated links that also hold id “someID” then they won’t work. To get the solution of this problem, Brandon Aaron (jQuery team member) developed a plugin called LiveQuery plugin which binds the events to these dynamically generated elements.
Now if you have some dynamically generated elements. Use your event like this:

$('a#someID').livequery('click', function(e) {
// your code
});
// or something like
$('a#someID').livequery('mouseenter', function(e) {
// your code
});
// or something like
$('a#someID').livequery('focus', function(e) {
// your code
});

I have used this plugin in my zGrid development

Add To Facebook Stumble This Digg This Add To Del.icio.us Add To Reddit Add To Yahoo Add To Twitter


Written by ZeeShaN

ZeeShaN RasooL is a web developer who loves to work in latest technologies to create more interactive dynamic and beautiful web pages.







Enter your Email:

Click Here for Popular

Who I Am

Zeeshan Rasool

Software Engineer - PHP
Lahore - Pakistan

zeeshan(@)99points.info
Skype: zeeshan-rasool
gTalk: zishan.rasool85

Categories

Tags

Comments