Owlcarousel2: "Cannot read property 'clone' of undefined " when 1 item only

Created on 19 Aug 2014  路  11Comments  路  Source: OwlCarousel2/OwlCarousel2

When there is only 1 item and the carousel options are set to items: 1 and loop: true there is error:

Uncaught TypeError: Cannot read property 'clone' of undefined 

I suppose it's trying to find a second element to be cloned?

invalid

Most helpful comment

Removing "items: 1", just set items to the default of 3 for me, so I ended up with a squashed image to the left. It was better to deal with loop instead.

My solution was to define a variable which based on the number of items was set to true or false:

var isMulti = ($('.owl-carousel .item').length > 1) ? true : false

then simply set the object properties

carousel.owlCarousel({
    loop: isMulti,
    items: 1,
    nav: isMulti,
    dots: isMulti
})

All 11 comments

Please improve your bug report: https://github.com/OwlFonk/OwlCarousel2#bug-reports.

No response.

Hey, sorry I didn't see your answer.
Hmm, is there a newer version of the carousel because on my fiddle it doesn't seem to work? But it works on yours.

Your fiddle (working)
My fiddle (not working)

Yes, currently you have to use the latest develop: https://github.com/OwlFonk/OwlCarousel2#building. I'm sorry for that but currently I'm pretty busy so it will take a while before I finish the next beta.

I have the same issue.

I have the same issue too.

have some problem too

@pe6o, @Shaker-Hamdi, @notsu or @synnz - could somebody set up a new jsfiddle with the latest version so I can test this?

Hi @daviddeutsch

First, thank you for continuing the work on OwlCarousel 2! It was sad seeing that it was canceled.

I've created a fiddle with the latest dist from github and it seems to not be working correctly - http://jsfiddle.net/06vjpbzo/1/

loop: true and items: 1 are not a good combination, if you remove "items: 1" works

Removing "items: 1", just set items to the default of 3 for me, so I ended up with a squashed image to the left. It was better to deal with loop instead.

My solution was to define a variable which based on the number of items was set to true or false:

var isMulti = ($('.owl-carousel .item').length > 1) ? true : false

then simply set the object properties

carousel.owlCarousel({
    loop: isMulti,
    items: 1,
    nav: isMulti,
    dots: isMulti
})
Was this page helpful?
0 / 5 - 0 ratings