Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap Carousel Not Sliding

Tags:

I ran into an interesting issue. I'm pretty sure that the answer is very simple, but I just couldn't figure it out so I thought I look for some help.

Basically, my carousel doesn't slide. It just switches image. I even tried copying the exact HTML from the bootstrap site into my own page and it still doesn't slide. In application.js, the initialization is also has no argument.

// carousel demo $('#myCarousel').carousel() 

I notice that next and prev classes are added to each item when clicking pref/next button, but it doesn't seem to do the same thing on mine. I didn't see anything wrong when I debugged either.

What am I missing? I tested this in both latest Chrome and Safari.

like image 451
juminoz Avatar asked May 18 '12 22:05

juminoz


People also ask

Does bootstrap carousel need JavaScript?

Bootstrap uses their JavaScript util functions to make the carousel operate when a user clicks on the controls. In this code snippet below, you'll see a previous and a next arrow on either side of the image.

How do I make carousel not slide automatically?

carousel({ interval: false, }); That will make the auto sliding stop because there no Milliseconds added and will never slider next.

Why is Bootstrap Carousel not sliding?

In browsers where the Page Visibility API is supported, the carousel will avoid sliding when the webpage is not visible to the user (such as when the browser tab is inactive, the browser window is minimized, etc.).

How do you set intervals on carousel?

You can simply use the data-interval attribute of the carousel class. It's default value is set to data-interval="3000" i.e 3seconds. All you need to do is set it to your desired requirements.


2 Answers

You also have to add bootstrap-transition for the sliding to work, like so:

<script src="twitter-bootstrap-v2/docs/assets/js/bootstrap-transition.js"></script> 
like image 129
gabber12 Avatar answered Oct 03 '22 06:10

gabber12


I was having the same issue but with bootstrap v2.0.3 (which has transition bundled in), ended up adding the slide class to the carousel div

<div id="myCarousel" class="carousel slide"> 

then you just call:

$('#myCarousel').carousel(); 
like image 31
elliotcw Avatar answered Oct 03 '22 07:10

elliotcw