在AJAX请求之后再次运行jCarouselLite

我正在使用jCarouselLite来显示一个post滚动条,它会加载特定类别的post。 但是,我希望能够通过AJAX切换类别。

所以,我在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不太熟悉,所以我可能错过了一些明显的东西。

您可以在此处找到演示(横幅下方的中间列,滚动条下方的switchCategory按钮)。

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

文档在这里提到你可以用旋转木马来结束

 $('div.carousel').trigger('endCarousel') 

所以每次你需要更新轮播只是endCarousel然后再将jCarouselLite绑定到div

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

尝试设置:

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

在你的jCarousel代码之前:

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