owl-carousel 重新加载

1.初始化

<div class="carousel slide" data-ride="carousel">
      <div class="slider" id="slider">
      
            [#if productImages?has_content]
                   [#list productImages as productImage]
                       <img src="${productImage.medium!noescape}"/>
                   [/#list]
             [/#if]
       div>
div>
$(function() {
    $('.slider').owlCarousel({
         singleItem : true,
         autoPlay : true
    });
});

2.重加载

var images = data.productImages;//ajax获取需要更新的内容
$('.slider').html("");
for(var i = 0; i < images.length; i++){
      $('.slider').append('+images[i]['MEDIUM']+'"/>');
}
$('.slider').data("owlCarousel").reinit({
      items: 1,
      autoPlay: true,
});

你可能感兴趣的:(owl-carousel,reload,owl-carsoule,重新加载)