Gallery and Colorbox group images

Maanstraat picture Maanstraat · Mar 28, 2013 · Viewed 8k times · Source

I have a little gallery:

  • Big photo
  • Little thumbs at the bottom

When a user click on a thumb the big photo change and when you click it ColorBox load, so far so good.

Now i want that when a user is in the ColorBox he can navigate trough the images with the next a prev arrows but how can i do this? With the normal 'rel: 'gallery'' it wont work?

Here is my js:

$("#wrapper #right #detail #photo ul li .thumb").click(function() {
    var image = $(this).attr("rel");
    $('#image').hide();
    $('#image').fadeIn('fast');
    $('#image').html('<table><tr><td><a href="' + image + '" class="gallery"><img src="' + image + '" alt="" /></a></td></tr></table>');
    return false;
});

$('#wrapper #right #detail #big #image').on('click', 'a', function(e){
    e.preventDefault();
    $.colorbox({
        transition: 'elastic',
        href: this.href,
        rel: 'gallery',
        speed: 200,
        opacity: 0.4,
        scalePhotos : true,
        maxWidth : '800px',
        maxHeight : '700px'
    });
});

And the HTML:

<div id="photo">
    <div id="big"><div id="image"><table><tr><td><a href="gfx/detail/1.jpg" class="gallery"><img src="gfx/detail/1.jpg" alt="" /></a></td></tr></table></div></div>

    <ul>
        <li><a href="#" rel="gfx/detail/1.jpg" class="thumb gallery"><img src="gfx/detail/1.jpg" alt="" /></a></li>
        <li><a href="#" rel="gfx/detail/2.jpg" class="thumb gallery"><img src="gfx/detail/2.jpg" alt="" /></a></li>
        <li><a href="#" rel="gfx/detail/3.jpg" class="thumb gallery"><img src="gfx/detail/3.jpg" alt="" /></a></li>
    </ul>
</div>

Can somewone help me so that colorbox makes his next and prev gallery?

Answer

webdeveloper picture webdeveloper · Mar 28, 2013

Try initialize group before calling colorbox:

$('.gallery').colorbox({ rel:'gallery' });

Any success?