Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

168
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

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

about 4 years ago · Juan Pablo Isaza Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda