Reputation: 507
I'm trying to set up an image slider using jquery bootstrap carousel.
It seems to be fine, except that the slider is not working. When I click the "next" arrow, the image does not change.
What am I doing wrong?
Best wishes,
Faisal
JAVASCRIPT FILES
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script src="/assets/jquery.js"></script>
<script src="/assets/bootstrap-carousel.js"></script>
SCRIPT THROUGH WHICH I AM CALLING BOOTSTRAP CAROUSEL
<script>
$(function () {
// $('.carousel').carousel({ interval: 2000 })
$('#myCarousel').carousel()
});
</script>
VIEW
<div id="myCarousel" class="carousel">
<!-- Carousel items -->
<div class="carousel-inner">
<div class="active item">
…<img src="/assets/us1.jpg" style="height="200", width="200">
</div>
<div class="item">
…<img src="/assets/us2.jpg" style="height="200", width="200">
</div>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
</div>
Upvotes: 0
Views: 875
Reputation: 28
I think you need you to reference the id of the carousel in the next/prev links like so:
Edit: Well you had a lot of typos, your image style is invalid. And usually I dont even have to call out the carousel in js, i just give them all unique ids.
I would take a closer look at the docs http://twitter.github.com/bootstrap/javascript.html#carousel
<div id="myCarousel" class="carousel">
<!-- Carousel items -->
<div class="carousel-inner">
<div class="active item">
<img src="/assets/us1.jpg" height="200" width="200">
</div>
<div class="item">
<img src="/assets/us2.jpg" height="200" width="200">
</div>
</div>
<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
</div>
Well copy paste this into your view... It should work out of the box, if you have jquery loaded.
<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="item active">
<img src="assets/img/bootstrap-mdo-sfmoma-01.jpg" alt="">
<div class="carousel-caption">
<h4>First Thumbnail label</h4>
<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
</div>
</div>
<div class="item">
<img src="assets/img/bootstrap-mdo-sfmoma-02.jpg" alt="">
<div class="carousel-caption">
<h4>Second Thumbnail label</h4>
<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
</div>
</div>
<div class="item">
<img src="assets/img/bootstrap-mdo-sfmoma-03.jpg" alt="">
<div class="carousel-caption">
<h4>Third Thumbnail label</h4>
<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" data-slide="prev">‹</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">›</a>
</div>
Upvotes: 1