Tony Testa
Tony Testa

Reputation: 109

jQuery jCarousel - how to remove the jCarousel from an element

I am using jCarousel to have a carousel of images in my page. It works great and I have no complaints, but I am using the tabbing on the page and when I go to another tab, there is an ugly jCarousel error. Basically what I want to do is to remove the jCarousel from my element when I go to 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?

Upvotes: 8

Views: 3664

Answers (5)

keypaul
keypaul

Reputation: 497

If need only to remove jCarousel, you can use destroy method http://sorgalla.com/jcarousel/docs/reference/api.html#destroy

Upvotes: 1

Joel
Joel

Reputation: 665

You should not do this as it is a horrible solution :P :

You could hide the carousel using CSS and then use .hide and .show based on what tab you are on.

$("#myelement #yourcarouselIDorClass").hide()

Upvotes: 0

ars265
ars265

Reputation: 1987

This functionality is currently broke in jcarousel. The remove method exists but does not provide the desired result. An issue was submitted here:

https://github.com/jsor/jcarousel/issues/338

As a workaround, none of which work correctly without breaking the carousel see the discussion here:

Removing an item from jCarousel plug-in

Upvotes: 0

Russ Cam
Russ Cam

Reputation: 125498

There doesn't seem to be a remove function as part of the plugin.

You could dig into the source and build one, or a quicker mechanism may be to clone myelement, remove the element and then replace with the cloned version.

Upvotes: 0

Related Questions