Cruising2hell
Cruising2hell

Reputation: 133

problem with lightbox

I am having problem with making my thumbnails as lightbox.

Link: http://www.ceanagupta.com/

The images are loaded off Flickr. After load, I want to implement the lightbox, but I am getting JavaScript error:

jQuery(".picasaGalleryItem").colorbox is not a function

Maybe this is something basic, and I am missing something.

Upvotes: 0

Views: 229

Answers (3)

Ivan Nikolchov
Ivan Nikolchov

Reputation: 1574

The nasty solution is to replace:

    setTimeout(function(){
        jQuery(".picasaGalleryItem").colorbox();
    },2000);

with

    $(document).ready(function(){
        var _colorbox = $.colorbox;     

        setTimeout(function(){
            _colorbox.apply($('.picasaGalleryItem'));   
        }, 2000);
    });

But seriously... don't unclude jquery twice

Upvotes: 1

Reto Aebersold
Reto Aebersold

Reputation: 16624

Have a look at the ColorBox FAQ. If I look at the requests I see jquery.min.js twice.

Upvotes: 3

VNO
VNO

Reputation: 3695

For starters, you should wrap your jQuery code in $(document).ready like so (the DOM is not guaranteed ready at the time of execution):

$(function() { //CODE HERE });

Second, you will need to make sure that the images and containing <div> are loaded before you actually execute colorbox on those DIVs. Since you are loading the image gallery asynchronously, you will need to implement a callback function that executes after the images are loaded, with the colorbox function inside. As far as I can tell, you will need to implement this inside of your picasa.js file.

Upvotes: 1

Related Questions