Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
how to remove eventhandler from bootstrap carousel indicator items

I am using bootstrap5 carousel, and I want to fire a custom event when the previous or next indicators are clicked. I want to prevent the default bootstrap event from firing. I have tried a bunch of different techniques, but with no success.

Does anyone know how to do this?

Mtia

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Check the official documentation. It has some listeners you can add to your JavaScript.

You need to make sure you add the Bootstrap CDN or the npm module with the JavaScript for it to work, though.

Bootstrap Documentation

Example

const myCarousel = document.querySelector("#myCarousel");
const carousel = new bootstrap.Carousel(myCarousel, { interval: 2500 });

myCarousel.addEventListener("slide.bs.carousel", () => { /* Do something... */ });
about 4 years ago · Juan Pablo Isaza Report

0

Have you tried e.stopPropagation() or e.stopImmediatePropagation()

about 4 years ago · Juan Pablo Isaza Report

0

I found the solution in the end. I was programatically placing bs-slide-to on the next and previous indicators, and this was causing the event handler to fire. So, to stop the bootstrap event handler, remove the bs-slide-to and the bs-slide attributes from the next and previous indicators, and the event won't fire. I removed that, and used a custom event handler and it works fine (I hope).

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!