JavaScript Fails to load content correctly on start
Posted
by
Gaz_Edge
on Stack Overflow
See other posts from Stack Overflow
or by Gaz_Edge
Published on 2012-10-25T22:21:26Z
Indexed on
2012/10/25
23:01 UTC
Read the original article
Hit count: 132
JavaScript
|jQuery
I have inherited an image gallery constructed using javascript. I believe it uses a variation of JQuery, but it seems to have been heavily edited.
The gallery loads the first image on page load. Each image has comments below them. There are forward and backward arrows that move between images.
The problem I seem to have is that if there is a comment on image one, it is not loaded on page start, the only way to get it to display is to click forward to the next image, then click back to image one. The comment is then shown.
All the comments are loaded into a script in the header under var sent_comments = [{COMMENTS}]
The comment HTML code on loading is as follows;
<div id="comments_container">
<div id="comments">
</div>
</div>
Once I have clicked to image two and then back to image one, the code is;
<div id="comments_container">
<div id="comments">
SOME COMMENT
</div>
</div>
Previous image button is:
<a class="prev save_state" href="#">
<img src="/next.png?" alt="Next">
</a>
Im new to javascript so not really sure what I will need to do to ensure the comment is loaded for the first image when the page loads.
Code here: http://static.albumexposure.net/assets/presentation-9f47b054d96f9ec2459e89619a5fe9b4.js
http://static.albumexposure.net/assets/presentations/book-699d82a2beb39df264e54c5d2578e0e4.js
© Stack Overflow or respective owner