Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery lazyload plugin and callback function

Tags:

jquery

i download jquery lazyload plugin from this site http://www.appelsiini.net/projects/lazyload.

from their doc i have not found that one can use any callback or not with lazyload plugin.

suppose my html look like

<div id="gallery" class="busy"><img src="blah.jpg" /></div>
<div id="gallery" class="busy"><img src="blah2.jpg" /></div>
<div id="gallery" class="busy"><img src="blah3.jpg" /></div>

my script like

$("#gallery img").lazyload();

class busy will just set a busy image at the center of div. so i need a callback and from the callback i need to detect image download completed or not if completed then i just remove the class from corresponding parent div of image tag .

so please show me the way to implement callback with lazyload and also need sample code by which i can remove the class from corresponding parent div of image tag .

thanks

like image 255
Keith Costa Avatar asked Dec 19 '11 06:12

Keith Costa


1 Answers

I had the same question. Did some searching, came here, and found the answer. This is wat I have, and works for me:

$(this).lazyload({
    effect : 'fadeIn',
    load : function()
    {
        console.log($(this)); // Callback here
    }
});

Hope this helps!

like image 96
Rick de Graaf Avatar answered Oct 13 '22 00:10

Rick de Graaf