单击按钮时使用Ajax和jQuery动态附加Owl转盘项目时,这些项目不起作用



我正试图使用jQuery和ajax调用将图像绑定到owl-carousel中,并使用按钮单击事件来显示owl-carlosel幻灯片中的所有图像,但单击后它将绑定div内容,但carousel无法工作。

甚至旋转木马也不工作,也不显示项目。

任何帮助都将不胜感激。。提前谢谢。

我在绑定后也尝试过重新加载旋转木马,但没有成功。

var owl = $("#myCarousel");
owl.owlCarousel({
items: 4,
itemsDesktop: [1199, 3],
itemsDesktopSmall: [980, 2],
itemsMobile: [600, 1],
navigation: true,
navigationText: ["", ""],
pagination: true,
autoPlay: false
});

您必须使用所有需要的选项重新初始化转盘。

var owl = $("#myCarousel");
var owlOptions = {
items: 4,
itemsDesktop: [1199, 3],
itemsDesktopSmall: [980, 2],
itemsMobile: [600, 1],
navigation: true,
navigationText: ["", ""],
pagination: true,
autoPlay: false
}; //set options in variable
//Init when page (document) ready
owl.owlCarousel(owlOptions);
//Doing some ajax manipulations
//...bla bla
success: function() { 
//...something heppened
owl.owlCarousel(owlOptions); //ReInit with options
}

最新更新