Anders Pedersen
Anders Pedersen

Reputation: 1034

jCarousel Lite - How can I link to a position in the carousel?

I have page with a jCarousel Lite carousel with some text and now I need to make a link on another page to a specific position in the carousel.

How can I jump to this position?

Upvotes: 1

Views: 538

Answers (1)

Dan
Dan

Reputation: 5637

If you're linking from another page to the page that contains the carousel, you could use a hash to go to a specific slide.

You could do something like this (with a hash value like www.example.com/#5)

function carousel_initCallback(carousel){

    var hash = window.location.hash;
    if(hash){
        carousel.options.start = jQuery.jcarousel.intval(hash.slice(1));
    } 

}

$(function(){

    $('#your_carousel_element').jcarousel({
        ...
        initCallback: carousel_initCallback
    });

});

Upvotes: 1

Related Questions