aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Loading dynamic number of images dynamically and attach onload event listner Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Loading dynamic number of images dynamically and attach onload event listner" Watch "Loading dynamic number of images dynamically and attach onload event listner" New topic
Author

Loading dynamic number of images dynamically and attach onload event listner

Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 509
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

Joined: Nov 06, 2012
Posts: 296
    
    5

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?


Read my books: Hello! HTML5 & CSS3 | HTML5 in Action | Read my blog
Saurabh Pillai
Ranch Hand

Joined: Sep 12, 2008
Posts: 509
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

Joined: Sep 12, 2008
Posts: 509
I got it working using jQuery like this.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loading dynamic number of images dynamically and attach onload event listner