views:

61

answers:

1

Hi everyone,

Using Lightbox for a photo gallery and would like to initiate the function by clicking on the thumbnail's parent <li>rather than the thumbnail image. I have been able to do this easily with the thumbnail for the album (not using Lightbox, simply opening another page) with the following code:

$(".item").click(function(){
        window.location=$(this).find("a").attr("href");return false;
    });

However, can't seem to initiate Lightbox in a similar fashion. Ideas?

Thanks!

UPDATE I am using jQuery Lightbox (0.5), http://leandrovieira.com/projects/jquery/lightbox/

Here is the code to initiate:

   $('a.lightbox').lightBox();

And the HTML (with PHP for details):

<a href="http://tapp-essexvfd.org/gallery/photos/&lt;?php echo $images['filename'];?>.jpg" class="lightbox" title="<?php echo $images['caption'];?>">
+3  A: 

You could catch the click of the <li> and then invoke the click event of the first <img> inside that <li> with the following code. But this is very hacky, and I do not recommend it. It would help to know which lightbox you're using (there are many), and see some HTML.

$(".item").click(function() {
  $(this).find(".lightbox:first").click();
});
GlenCrawford
Thanks, see update above.. :)
NightMICU
Will do. For reference, have you tried the above solution?
GlenCrawford
Yes, Firebug displays the following: i < length value = object[++i] ) {} After a few seconds, the image opens in another browser window.. Lightbox does not initiate
NightMICU
Correction! This is the correct solution, accidentally erased the Lightbox function from my code. Many thanks! :)
NightMICU
Good to hear that it's working. Glad to help!
GlenCrawford