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

236
Vistas
How to load Bootstrap Modal in the presence of a javascript function that reloads the page every second?

I use Bootstrap 4.7 Modal on a page. This page also has a javascript function that reloads the page every second, e.g.,

setInterval(function () {
            somefunction();
        }, 1000);

The problem is that the Modal doesn't work. I guess it doesn't because the moment it pops up the page has to reload so it fails. Then I believe I need to tell setInterval to stop reloading if Modal is active? Is there an easy way around this? Thanks a lot

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you save the interval as a variable, you can stop it later hen a button is clicked (for example).

var myTimer = setInterval(function () {
  somefunction();
}, 1000);

Now just call clearInterval(myTimer) to stop it.


Or, let's really simplify it like this.

var myTimer = null;

function startTimer() {
  myTimer = setInterval(function () {
    somefunction();
  }, 1000);
}

function stopTimer() {
  clearInterval(myTimer);
}

Now you just need to call startTimer() and stopTimer()

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