Leandro Zhuzhi
Leandro Zhuzhi

Reputation: 314

javascript weird behaviour

i have some code that tries to list images based on their height. the weird thing is that the same code kinda works when i try with 2 images but doesn't work when i try with 3 or more

site: http://bit.ly/JV5I0Z

if you click on a menu button, the images should list themselves one below the other filling a width as wide as that black line thingy. if you click the 1st button that creates 2 thumbnails they work but the other buttons dont do nothing

code: http://jsfiddle.net/5qt3s/

i have tried to remove all irrelevant stuff to keep it as simple as possible

what could i be doing wrong? thanks

Upvotes: 0

Views: 67

Answers (1)

pjumble
pjumble

Reputation: 16960

You only have two small images on your webspace (euroscala.balkanium.com):

images/shkalla/small/1.jpg
images/shkalla/small/2.jpg

images/shkalla/small/3.jpg doesn't exist so when it gets to this image (in the loop inside createThumbs) instead of firing the img.onload event it fires img.onerror, because it fails to load the image. This means your totalLoaded count never reaches totalThumbs and redrawThumbs doesn't get called.

Either create the missing images, or hook into the img.onerror event and skip the image.

Upvotes: 2

Related Questions