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

151
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
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