Owl Carousal2 with items 1 and loop true

Ashish Mehta picture Ashish Mehta · May 26, 2015 · Viewed 16.5k times · Source

Console Error : TypeError: items[clones[(clones.length - 1)]] is undefined. this error due to only one item div and property loop true and item 1. So. any solution at this situation. I know this type of Situation does not occurs but if any solutions please tell me Thanks a lot.

Answer

Balloonatic picture Balloonatic · May 27, 2015

Add onInitialize and check how many items the carousel contains. If the carousel has 1 or less items, set loop to false.

$(document).ready(function(){
  $('.owl-carousel').owlCarousel({
    loop:true,
    margin:10,
    nav:true,
    items: 1,
    onInitialize: function (event) {
        if ($('.owl-carousel .item').length <= 1) {
           this.settings.loop = false;
        }
    }
  })
});