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

211
Views
Cannot trigger function on Vuetify v-alert close

I am trying to call a function when a Vuetify v-alert is closed. Nothing I have seen in the docs covers it. As you can see in the codepen example, there is a dismissible attribute which is used to add the ability to close the alert. But nothing I have tried allows a function to be called at the same time.

I have tried several regular Vuetify ways to achieve this such as,

v-on:onclick="func()", v-on:click="func()", and simply @click="func()", but it seems that a function cannot be called from a v-alert.

Note that I want to keep the dismissible attribute that smoothly removes the alert automatically when the close icon is clicked. I don't need to call a function to remove the alert itself, but to do something else after the alert is removed.

Any help much appreciated!

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

0

You can use @input on the v-alert element:

<v-alert @input="foo">

foo will be called when the [x] is clicked.

about 4 years ago · Juan Pablo Isaza Report

0

Vuetify provides the close slot specifically for this use case. From the slot you call any method, and the scoped toggle method to close the alert.

<template v-slot:close="{ toggle }">
  <v-btn @click="closeAlert(toggle)">Close</v-btn>
</template>
closeAlert(toggle){
  toggle()
  console.log("alert closed")
}

See the working codepen

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!