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

229
Visualizações
Vue click event not emitting properly to div

As shown in the code, I want to get a click event to trigger the pop up 'add-day-form' which is a component. But by putting the @click="showModal = true" in the wrapping div, when the pop up appears I cannot seem to press the close button that emits the close event. I only get it to close if i put the @click="showModal = true" on the font-awesome-icon. The component apears in both situations but the close event seems to only work when its not in the outside div (plusContainer) which is where I want it to be

*edit: it seems that if I listen for a dblclick event on the plusContainer, everything seems to work fine except for now I have to double click to open the component which is not ideal

I copied the vue pop-up modal from their site here https://vuejs.org/v2/examples/modal.html

here is the app.vue

<template>
   <div class="plusContainer" @click="showModal = true">
       <font-awesome-icon style="color: white" class="fa-sm" icon="plus" />
       <add-day-form v-if="showModal" @close="showModal = false" />
   </div>
</template>

<script>
import addDayForm from "./addDayForm.vue";
import dayView from "./dayView.vue";
export default {
   components: {
       addDayForm,
       dayView,
   },
   data() {
       return {
           showModal: false,
       };
   },
};
</script>

here is the form component

<template>
    <div class="notifContainer">
        <div class="heading">
            <h2 id="title">Dayy</h2>
        </div>
        <button @click="$emit('close')">Close</button>
        <!-- <day-view></day-view> -->
    </div>
</template>
<script>
export default {};
</script>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It looks like the click event is propagating to the plusContainer so it does a close and then immediately open again.

You may try to do: @click.stop="$emit('close')" on the form component:

<template>
    <div class="notifContainer">
        <div class="heading">
            <h2 id="title">Dayy</h2>
        </div>
        <button @click.stop="$emit('close')">Close</button>
        <!-- <day-view></day-view> -->
    </div>
</template>
<script>
export default {};
</script>
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