Search code examples
javascriptjquerycolorbox

adding callback on colorbox to skip the first image of slideshow


Weird requirement, but I want to skip only the first slide on my slideshow (made with colorbox). So basically, what I want is that the first slide doesn't show and slideshow opens with the second slide.

The only way I can think of achieving it through doing the "go next" on "onLoad" function but I am not sure how to make it go next only for first image.

This is what I have done:-

$(".element").colorbox({
    onLoad:function(){
        $.colorbox.next();
    }
});

Unfortunately, even "next()" is not working. I am not sure how to achieve that. Any idea how to achieve it through this or may be some other way?

Thanks.


Solution

  • Disclaimer: I like Rob's idea to $.remove the element more than the idea below but if your heart is set on not mucking up the CMS' DOM...

    I'm not sure but this may be a scope thing:

    You could try binding the event to the DOM:

    $(document).on('cbox_complete', function(){
      $.colorbox.next();
    });
    

    (I would try with the complete event first and then experiment from there)