Reputation: 7165
I am having a hard time to achieve this thing. I want to add element on my ul
on runtime, but this doesn't work properly on jCarouselLite.
When I add li
element, it just adds at the bottom but not aligned with the flow.
For you to get what I mean, see the code here
Hope someone could help.
Upvotes: 0
Views: 786
Reputation: 10839
jCarouselLite
doesn't appear to support dynamic addition of elements. You may want to consider using jCarousel instead which does seem to have support for this.
When you add your li
it is being wrapped onto the next line because jCarouselLite
has set an explicit width on your ul
element. You can stop the li
from wrapping, by adding to its width as you add the new li
item:
$("#list").width(52 + $("#list").width());
However, this doesn't solve the problem because the jCarousel
object contains a private member variable itemLength
which is uses to do boundary checking, so it stops before you can get to the end of the Carousel and see the new added item.
You may be able to fudge something by removing + then recreating the Carousel, but it if you need the functionality, it feels like you should try and use a plugin that supports it out of the box.
Upvotes: 1