init() doesn't seem to fire... because its a generated gallery?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

init() doesn't seem to fire... because its a generated gallery?

Wintermute-2
Using Shadowbox with the script below: I'm getting no errors, the page validates, but clicking a thumbnail just loads the link href (ie: the fullsize image) rather than firing Shadowbox. I'm clearly doing something stupid - am I initialising Shadowbox incorrectly, or is it something to do with the fact that the code for the thumbnails is generated on page load?

----------------------------------------

<script type="text/javascript" src="js/prototype.js"></script><script type="text/javascript" src="js/scriptaculous.js?load=effects"></script><script type="text/javascript" src="js/shadowbox-prototype.js"></script><script type="text/javascript" src="js/shadowbox.js"></script>    <script type="text/javascript"> /* <![CDATA[ */ var aKidPics = [ ['alfie.jpg','Alfie'] ,['amy.jpg','Amy'] ,['angelos.jpg','Angelos'] ,['arthur.jpg','Arthur'] ,['ben.jpg','Ben'] ,['bruno.jpg','Bruno'] ,['charlie.jpg','Charlie'] ,['Eklavya.jpg','Eklavya'] ]; Event.observe(window, 'load', function() { var sHTML = ""; for (i=0; i<aKidPics.length; i++){ sHTML += '<div class="thumbpic">'; sHTML += ' <a href="img/ifyoucould/'+ aKidPics[i][0] +'" rel="shadowbox[IfYouCould]" title="'+ aKidPics[i][1] +'">'; sHTML += ' <img src="img/ifyoucould/thumbs/'+ aKidPics[i][0] +'" width="100" height="75" border="0" />'; sHTML += ' </a>'; sHTML += ' <p>'+ aKidPics[i][1] +'</p>'; sHTML += '</div>'; $('ifyoucould_gallery').innerHTML = sHTML; } var shadowboxOptions = { assetURL: 'img/ifyoucould/', animSequence: 'sync', loadingImage: 'img/shadowbox/loading.gif', overlayBgImage: 'img/shadowbox/overlay-85.png' }; Shadowbox.init(shadowboxOptions); }); /* ]]> */ </script>

-----------------------------------
ETA: wtf is nabble forum and why can't it parse code properly??? :/ The code that it's borked above should read (without the spaces that I've just shoved in):

sHTML += '< div class="thumbpic">';
sHTML += ' < a href="img/ifyoucould/'+ aKidPics[i][0] +'" rel="shadowbox[IfYouCould]" title="'+ aKidPics[i][1] +'">';
sHTML += ' < img src="img/ifyoucould/thumbs/'+ aKidPics[i][0] +'" width="100" height="75" border="0" />';
sHTML += ' </ a>';
sHTML += ' < p>'+ aKidPics[i][1] +'</p>';
sHTML += '</ div>';