0

**e.target.closest event triggering twice**

*I am using vuetify framework in my vuejs code.. on clicking v-card(overall), i want the page to redirect to another page, except on clicking 'toggle-switch' class. While clicking 'toggle-switch' class in v-card, it is entering into click function twice. i want it to enter only once . Why does the event triggered twice?*

here's my html code:

  <v-card
    class="text-left ticket-card"
    @click="goToTicketDetails($event, ticket)"
  >
    Some content
    <div class="toggle-switch">
      <v-switch
        v-model="ticket.isOpen"
        hide-details
        class="status-switch"
        :readonly="ticket.isReadOnly"
      ></v-switch>
      <p class="status-text">
        {{ ticket.isOpen ? "Active" : "Resolved" }}
      </p>
    </div>``your text``
  </v-card>

and here's the click function of v-card:

function goToTicketDetails(e, ticket) {
if (e.target.closest(".toggle-switch")) {
console.log("enter");
//while clicking on switch for activate/deactivate
updateTicketStatus(ticket);
} else {
//some code
}
}
4
  • You can try to use @click.prevent="clickFunction" Commented May 31, 2023 at 13:19
  • thanks for the comment. i tried @click.prevent already and it doesn't work Commented May 31, 2023 at 13:31
  • Do you have as function within the Vue methods:{}? Works fine for me .. please post a reproducible example Commented May 31, 2023 at 13:40
  • not using methods.. i m using vue3 composition api Commented Jun 1, 2023 at 7:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.