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

148
Views
Don't call popup if another one is already on the page

There is a popup (1) that should be called after 15 seconds of being on the page. But if the user opened some other popup(2), then don't call the first one.

popup(1);

mounted() {
 this.openModal();
},

// methods
openModal() {
  setTimeout(() => {
    this.isModalVisible = true;
  }, 15000);
},

How to do it? Perhaps need to stop setTimeOut?

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

0

Maybe something like following snippet:

new Vue({
  el: '#demo',
  data() {
    return {
      isModalVisible: false,
      isModalOther: false
    }
  },
  methods: {
    openModal() {
      setTimeout(() => {
        if(!this.isModalOther) this.isModalVisible = true;
      }, 5000);
    },
    openOtherModal() {
      this.isModalVisible = false
      this.isModalOther = true;
    },
  },
  mounted() {
   this.openModal();
  },
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="demo">
  <div v-if="isModalVisible">popup1</div>
  <div v-if="isModalOther">popup2</div>
  <button @click="openOtherModal">open popup2</button>
</div>

about 4 years ago · Juan Pablo Isaza Report

0

To cancel a timeout, all you need to do is call clearTimeout(TimeoutID);. A timeoutID is a returned by the setTimeout() method automatically, so just save it in a variable

let timer = setTimeout(...);

then, when you call popup(2), just add

this.clearTimeout(timer);

and the first popup won't show

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!