Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loading dynamic number of images dynamically and attach onload event listner

 
Saurabh Pillai
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a button to load images. When user clicks on it, it needs to bring back 6 images initially with an option to load more images. I am dynamically creating <table> and other necessary tags. I want to set onload event to every <image> tag. This is what I have so far.



But this function is not being called. Eventually, this function would be responsible to bring back the actual image. and each image block would be loaded dynamically and independently.

We are using all sorts of javascript technology from plain JS to jQuery and DWR. So solution using any flavor of javascript is fine.

Thank you.
 
Rob Crowther
author
Ranch Hand
Posts: 297
5
Android Fedora Firefox Browser
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nowhere in the code you've posted is the image actually being loaded, so my guess would be that the image has already been loaded by the time you attach the handler. What does getImageElement() do?
 
Saurabh Pillai
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code that I have posted is preparing the structure to host image. so what I want is when I have <image> element ready, I want to call a function to fetch the image and set it to this element. And I assume onload event of <image> element is best suited.

What does getImageElement() do?

 
Saurabh Pillai
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it working using jQuery like this.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic