-
-
Notifications
You must be signed in to change notification settings - Fork 10
[Feature Request] Vuetify alert(), confirm() and prompt() #16
Description
Problem to solve
The standard JavaScript popups look different for every browser and often don't fit Material Design. Also, adding a popup to the template of every component where you want to have a confirm dialog is annoying.
Proposed solution
- <v-btn @click="deleteDialog = true">Delete</v-btn>
+ <v-btn @click="deleteItem">Delete</v-btn>
- <v-dialog v-model="deleteDialog" max-width="500px">
- <v-card>
- <v-card-title>Delete item?</v-card-title>
- <v-card-actions>
- <v-spacer></v-spacer>
- <v-btn color="primary" flat @click.native="deleteDialog = false">Cancel</v-btn>
- <v-btn color="primary" flat @click.native="deleteItem">Delete</v-btn>
- </v-card-actions>
- </v-card>
- </v-dialog>
...
// deleteItem function
+ if(await this.$vuetify.confirm("Delete item?")){
+ // original deleteItem code
+ }Even if you put the delete dialog above inside it's own file, you still need a local variable that controls the dialog's visibility. With $vuetify.<popup name>, you can handle the whole logic within a single method.
- if(window.confirm("Do you want to continue")){
+ if(await this.$vuetify.confirm("Do you want to continue")){
doSomething();
}- const input = prompt("What is your name")
+ const input = await this.$vuetify.prompt("What is your name")Alert, confirm and prompt should be implemented by Vuetify, but users should have the ability to define their own popups by
- passing components to the
Vuetifyconstructor - using scoped slots inside
VApp - or like this
this.$vuetify.customPopup(MyCustomPopup, "Do you want to continue")
Components get all data passed to $vuetify.<popup name> using the vuetify-popup prop or scoped slots and can return data using $emit("update:vuetifyPopup", <data to return>). Emitting update:vuetifyPopup also causes components to be unmounted.