在运行时重新初始化jCarouselLite

时间:2011-11-14 12:16:15

标签: javascript jquery

有谁能告诉我如何在运行时重新初始化jCarouselLite插件。我在一个页面中有5个滑块,我想在滑块之间切换。所有代码都完成了。我想要的是在当前滑块的运行时重新初始化“jCarouselLite”插件。我的代码如下:

   if(isNext){
    /* Removing Slider */
    $(current_selector).jCarouselLite = null;
    $(".btn_prev"+current).unbind('click');
    $(".btn_next"+current).unbind('click');

            /* Re-initializing Slider */
    $(current_selector).jCarouselLite({
        btnPrev: ".btn_prev"+current,
        btnNext: ".btn_next"+current,
        circular: false,
        visible: 1,
    });
}else{  alert("in prev");}

任何帮助将不胜感激。感谢。

1 个答案:

答案 0 :(得分:0)

这对我有用:

var theModelCarousel = null;
$(current_selector).jCarouselLite({
......
initCallback: modelCarousel_initCallback 
});
//and the function

function modelCarousel_initCallback(carousel) {
theModelCarousel = carousel;
// Callback functuions if needed
};

function clearModelCarousel() {
theModelCarousel.reset();
theModelCarousel.add(0,someImageURL1);
theModelCarousel.add(1,someImageURL2);
theModelCarousel.size(2);
    }