malsup / cycle2

2nd gen cycling
899 stars 236 forks source link

carousel.onDestroy method throws error #377

Open kennykaye opened 10 years ago

kennykaye commented 10 years ago

Error: "Uncaught TypeError: Cannot call method 'remove' of undefined "

This issue occurs when destroying and initializing slideshows with different transitions, i.e.: carousel and fade.

Specifically, when the carousel plugin attempts to call the "remove" method on the "opts._carouselWrap" object, however under this specific circumstance, the carouselWrap object does not exist.

kennykaye commented 10 years ago

Proposed fix:

On line 265 of jquery.carousel.js change:

    opts._carouselWrap.remove();

to

    if(opts._carouselWrap)
    {
        opts._carouselWrap.remove();
    }
wlanni commented 10 years ago

Yep, I'm running into the same thing. I'm swapping out the carousel with a grid of the images. I destroy the cycle and wrap the elements in a ul and LIs. if I resize the browser while in this grid, it somehow thinks the opts._carouselWrap is still in existence and starts throwing errors.

stevenMouret commented 9 years ago

Same problem, fix works, thx.

gaswirth commented 9 years ago

Over 2 years later? This fix still works, with cycle2!

sbonardt commented 7 years ago

Fix works. It's not in yet, so if you're having problems with destroying a carousel this is the way 👍