Reputation: 1253
I have an ASP.NET UpdatePanel that can contain many images, and I want to execute some javascript whenever the UpdatePanel is updated, but I don't want it to occur until after all of the images are loaded. I've tried setting up my function as a callback via add_endRequest. This will execute the function after the UpdatePanel's asynchronous postback, but it does not wait until all of the images are loaded. Does anyone have any good suggestions on how I can delay the execution of the function until the images have completely loaded?
Upvotes: 3
Views: 384
Reputation: 40736
Likely you have to handle the load
event of each image on your own and sum up until you've loaded all.
So you have to count all images, subscribe to their load events, remember when each load was called (e.g. incrementing a global JavaScript variable) and when the last one was loaded, you can call the actual "finished loading all images" function.
Upvotes: 3