0

I have a jQuery function one for lot of .class objects, and I want to call a function complete after .one function was called on all .class objects.

This is .one function

$(".pas_img").one("load",function()
{
   //some code here
}).each(function() 
{
   if(this.complete) $(this).load();
});

EDIT:

OK, I am using a function from jQuery callback on image load (even when the image is cached) (the answered solution) for lot of images and dynamically resize them when the image is cached by the browser, and I need to call function when all images are cached so when function .one("load") was called to all objects.

wuerfelfreak
  • 2,363
  • 1
  • 14
  • 29
user2825860
  • 11
  • 1
  • 2

1 Answers1

0

Try this:

 (function () {
     var totImgs = $('.pas_img').length;
     $(".pas_img").one("load", function () {
         if (!--totImgs) {
             alert('all images loaded');
         }
     }).each(function () {
         if (this.complete) $(this).load();
     });
 }());
A. Wolff
  • 74,033
  • 9
  • 94
  • 155