Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

118
Visualizações
Why my Bootstrap Modal loads incomplete after using clear Interval

Every 2 seconds I update a table on my page. This table has a Modal button that also contains information and therefore it is also updated every 2 seconds. The problem is that the info in the Modal doesn't load after using clear Interval. (No need to say that I do need to use clear Interval because Modal doesn't work with the table updating constantly). The code is as follow

    var myTimer;

    function startTimer() {
      myTimer = setInterval(function () {
        somefunction_to_updatetable();
      }, 2000);
    };
    
    function stopTimer() {
      clearInterval(myTimer);
    };
      
    $(document).on('show.bs.modal', '#idModal', function (e) {
      stopTimer();
    });

      window.onload = function() {
        startTimer();
      };

In this code, when loading the page setInterval is defined with window.onload. It starts updating info in the table every 2 seconds. When I click the Modal button, stopTimer is read and setInterval is cleared. The Modal opens but the info is not there, only info that is not part of somefunction_to_updatetable() is present in the Modal... how can I fix this? I feel it is straightforward from where I am but I really cannot find a way

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda