ringstaff
ringstaff

Reputation: 2325

Fire event on carousel slide (not slid) event, Bootstrap 3

Bootstrap 2 seems to work fine handling the slide event (see this question) with the following code:

$('#myCarousel').bind('slide', function (e) {
    console.log('slide event!');
});

I cannot, however, get the same things to work in Bootstrap 3 (see this fiddle). Anyone know why?

Upvotes: 6

Views: 29987

Answers (2)

Harikaran K
Harikaran K

Reputation: 428

On Slide before

h('#HomeSlider').bind('slide.bs.carousel', function (e) {
   alert(h('#HomeSlider .item.active').html());
});

On Slide After

h('#HomeSlider').on('slid.bs.carousel', function (e) {
   alert(h('#HomeSlider .item.active').html());
});

Upvotes: 9

PSL
PSL

Reputation: 123739

Actual event namespace for slide according to bootstrap3 implementation is slide.bs.carousel as opposed to slide which was the one acc: to BS2, also use slid.bs.carousel to track completion of slide (though slid seems to work.)

So try:

$('#myCarousel').bind('slide.bs.carousel', function (e) {
    console.log('slide event!');
});

Demo

Upvotes: 23

Related Questions