PDA

View Full Version : Simple Controls Gallery v1.4 hangs on ajaxload.gif with ie7



nova62400
06-02-2011, 12:00 AM
1) Simple Controls Gallery v1.4

2) http://www.dynamicdrive.com/dynamicindex4/simplegallery.htm

3) Describe problem:

You can verify this by going to the script demo page (I'm using ie7 on XP):
It works normally when visiting the page for the first time, or when refreshing. However, navigate to any other page and then back and you'll see it's hung on the ajaxloading.gif. Entering the url again, or seleting the url in the address bar and pressing enter also triggers the issue.

Please let me know if you can come up with a solution, other than that it's great. Thank you.

jscheuer1
06-02-2011, 01:46 AM
I've moved this to bug reports since its reproducible on the official demo page, just as you say. It also happens in IE 9 on Windows 7 if you view it in the IE 7 or IE 8 modes.

There's an easy fix though. Find this section in the simplegallery.js script (around line #41):


for (var i=0; i<setting.imagearray.length; i++){ //preload slideshow images
preloadimages[i]=new Image()
preloadimages[i].src=setting.imagearray[i][0]
if (setting.imagearray[i][3] && setting.imagearray[i][3].length>setting.longestdesc.length)
setting.longestdesc=setting.imagearray[i][3]
jQuery(preloadimages[i]).bind('load error', function(){
loadedimages++
if (loadedimages==setting.imagearray.length){
dfd.resolve() //indicate all images have been loaded
}
})
}

Move it up a little like so:


for (var i=0; i<setting.imagearray.length; i++){ //preload slideshow images
preloadimages[i]=new Image()
jQuery(preloadimages[i]).bind('load error', function(){
loadedimages++
if (loadedimages==setting.imagearray.length){
dfd.resolve() //indicate all images have been loaded
}
})
preloadimages[i].src=setting.imagearray[i][0]
if (setting.imagearray[i][3] && setting.imagearray[i][3].length>setting.longestdesc.length)
setting.longestdesc=setting.imagearray[i][3]
}

The key is to bind the onload/onerror code to the image before the src is assigned. What was happening was that, with everything cached the load event was firing before the behavior for it was bound. With this new order to the code that cannot happen.

speedygonzales77
06-13-2011, 04:58 PM
Thank you for sharing the solution. I have applied it on our site and are testing it at the moment without a problem.

R. Vreeken
10-09-2011, 12:12 PM
Hi,
I have the same problem and tried the solution as stated above. Unfortunately, without any succes. Any other advice?
Thanks

jscheuer1
10-09-2011, 04:33 PM
Hi,
I have the same problem and tried the solution as stated above. Unfortunately, without any succes. Any other advice?
Thanks

If you truly have the same problem, and the script hasn't been updated in some way that makes using this solution impractical/more challenging since the solution in this thread was put forth (check the dates on the posts visa vis the update history of the script), just make sure you've saved the changes and are using the new simplegallery.js script file.

The browser cache may need to be cleared and/or the page refreshed to see changes.

If you want more help:

Please post a link to a page on your site that contains the problematic code so we can check it out.

R. Vreeken
10-09-2011, 06:31 PM
John,
Thanks for your reply.
In the meanwhile the problem is solved. At first I moved the code on one of my webpages and left the code on other webpages unchanged. This didn't help untill I moved the code on all pages.
Now it works fine.

Thanks again.