jCarousel unload / disable / remove

PaDalton picture PaDalton · Nov 29, 2010 · Viewed 7.6k times · Source

I am using jCarousel to have a carousel of images in my page. It works great and have no complaints, but I am using the tabbing on the page and when I goto another tab, it get an ugly jCarousel error. Basically what I want to do is to remove the jCarousel from my element when I goto a new tab but for the life of me can't figure it out

To add the carousel I am using code like this $("#myelement").jCarousel({ /* config params */});

But I am unsure of how to remove .jCarousel from $("#myelement") any ideas?

Answer

Nick Devereaux picture Nick Devereaux · Jun 19, 2012

In addition to PaDalton's answer, I also detached the resize event from the window as my carousel was inside a (colorbox) popup box.

$(window).unbind('resize.jcarousel');

When the event got triggered, the $(this).dimensions(e) line sent the alert message as the li node didn't have a size, it thought the the object was to be displayed but without a size it would not be able to compute the carousel dimensions properly.

The error message was Infinite Loop - no width or height set