Fire event on Bootstrap carousel slide issue
22,825
Bootstrap 3 changed the 'slide' event to 'slide.bs.carousel'. Change to this and it should work (assuming that is your only issue):
$carousel.bind('slide.bs.carousel', function (e) {
console.log('slide event!');
});
See this question.
Author by
sdvnksv
Updated on July 05, 2022Comments
-
sdvnksv almost 2 years
I try to use this code to fire on an event upon carousel slide, but it fails to work for some reason. Any suggestions?
var $carousel = $('#carousel-showcase'); $carousel.carousel(); $carousel.bind('slide', function(e) { setTimeout( function(){ var left = $carousel.find('.item.active.left'); var right = $carousel.find('.item.active.right'); if(left.length > 0) { $("#wrap").animate({ backgroundPositionX: '+=50%' },0); } else if(right.length > 0) { $("#wrap").animate({ backgroundPositionX: '-=50%' },0); } }, 500); });
-
sdvnksv over 10 yearsit works in Chrome, but fails to work in Mozilla. Any suggestions?
-
sdvnksv over 10 yearsYes, it turned out that Mozilla has problems with animate(backgroundPositionX). I managed to fix it with a plugin. Now it works fine.
-
Pupil over 7 yearsI have searched everywhere for this question and finally got this answer. Thanks.