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>
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
Well copy paste this into your view… It should work out of the box, if you have jquery loaded.