Hello,
Has anyone got an example of destroying a carousel and then re-enabling it later on?
I'm basically destroying a carousel on small devices and then trying to re-enable the carousel when its resized back to large devices.
When I destroy the carousel and resize i get errors in the console:
Uncaught TypeError: Cannot read property '_checkVisibile' of null
Uncaught TypeError: Cannot read property '_onResize' of null
Not sure if its a bug or something I'm doing wrong.
Thanks
Sorry but you have to re-create the carousel:
$('.owl-carousel')
.owlCarousel({...})
.owlCarousel('destroy')
.owlCarousel({...})
A re-enabling will be not possible in the near feature.
This is a bit of a deal breaker as jasonalvis explains...with responsive website you sometimes need to destroy and recreate the carousel depending on the viewport size, please fix this bug!
This is nether a bug nor a "deal breaker". You're able to destroy and (re)create, see above. But there will be no single method for this. That's all :).
I think we've side tracked a bit with the point.
I'm happy to destroy and re-create the carousel, this is fine and how I expected it to be. The problem is when I destroy the carousel and then carry on resizing the browser I get a JS error which reads:
Uncaught TypeError: Cannot read property '_onResize' of null
It looks like the _onResize is still being ran even though the carousel was just destroyed?

First of all, I must say OwlCarousel is turning to be one of the greatest jQuery carousels I worked with it.
I'm having the exact same problem. My code is something like this (not the real code, just an example, the real code builds an assortment of slides with several items on each slide):
$photoCarousel = $('#my-carousel');
$photoCarouselHTML = '
//... then, on a
It works, but everytime I resize the browser (Desktop) it throws that exact same error @jasonalvis mentioned above. You can see my application on http://www.iguatemiportoalegre.com.br/monsterhigh/ (website in portuguese, code with mostly english comments/variable names). My carousel in this case is the one at the bottom of the page.
@jasonalvis that's exacly my point, thank you. I don't mind recreating the carousel it's just when I do, there is a bug in javascript. Thus, making it a deal breaker.
I'm pretty sure you guys don't use the latest develop?
I took it directly from this repo no longer then a week ago
Have anybody read the README regarding bug reports? :)
Here is something very usefull for such discussions: http://jsbin.com/lenosokomexe/1/edit
Beside that for the destroy method exists an unit test. So I'm pretty sure you're using an outdated version...
woah you're right :
http://jsbin.com/boyiyunomaki/2/
I did find the js on your repo though, I don't understand
anyone looking at my jsbin...resize browser
This should help: https://github.com/OwlFonk/OwlCarousel2#building.
yeah I tried to not use grunt and get the js minified directly from the repo.
anyway thanks a lot
I can also confirm I've got it working, strange though as I also took the JS directly from this repo just a few days ago.
anyway we got it resolved in the end, thanks for your help!!
Oh I actually think I downloaded it here : http://www.owlcarousel.owlgraphic.com/
@witrin did you update the files on the website as well? I believe that's where I got it and not the repo
@stephenbe I've no access to the websites of the owner, I'm just the collaborator ;). But I'm a little worried about the owner because I'm not able to reach him since July...
I think we all downloaded it over there...I'm worried as well...=s
@stephenbe Yep your right I got it from the site too!
I solved with this code:
$(".carousel-mini").each(function () {
$(this).owlCarousel('destroy');
});
instead this:
$(".carousel-mini").owlCarousel('destroy');
Sorry but you have to re-create the carousel:
$('.owl-carousel') .owlCarousel({...}) .owlCarousel('destroy') .owlCarousel({...})A re-enabling will be not possible in the near feature.
thanks @witrin , this works!