2012-02-24 118 views
0

我正在使用jCarouselLite显示后滚动器,该滚动器从特定类别加载帖子。但是,我希望能够通过AJAX切换类别。在AJAX请求后再次运行jCarouselLite

所以,我加载了一切在一个div,然后运行:

jQuery(function($) { 
$("#serviceNews").jCarouselLite({ 
    vertical: true, 
    hoverPause:true, 
    visible: 2, 
    auto:2000, 
    speed:1000 
}); 

});

它的工作原理...直到ajax刷新#serviceNews的innerHTML。然后jCarouselLite停止工作。我试过使用livequery:

jQuery(function($) { 
$("#serviceNews").livequery(function(){ 
    $(this).jCarouselLite({ 
     vertical: true, 
     hoverPause:true, 
     visible: 2, 
     auto:2000, 
     speed:1000 
    }); 
}); 

});

但同样的事情发生。我对jQuery不太熟悉,所以我可能错过了一些明显的东西。

你可以找到演示here(横幅下面的中间列,在滚动条下面有switchCategory按钮)。

回答

2

希望您使用的是最新的代码https://github.com/kswedberg/jquery-carousel-lite

的文档中提到这里,你可能会结束与

$('div.carousel').trigger('endCarousel') 
每次你需要更新转盘只是endCarousel,然后再结合时间

所以旋转木马jCarouselLite到div

1

maniac_user的解决方案正在为我工​​作。

尝试设置:

$("div.carousel").trigger("endCarousel"); 

您的jCarousel代码:之前

$(".auto .jCarouselLite").jCarouselLite({ 
    speed: 14700, 
    btnNext: ".next", 
    vertical: true, 
    hoverPause:true, 
    visible: 1 
});