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

240
Views
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 answers
Answer question

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 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!