Skip to content

Instantly share code, notes, and snippets.

@martinbean
Created November 10, 2018 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinbean/4469b5a44757a1ed7b1fd38eeb8a23c8 to your computer and use it in GitHub Desktop.
Save martinbean/4469b5a44757a1ed7b1fd38eeb8a23c8 to your computer and use it in GitHub Desktop.
Promise-based Vue.js confirmation dialog mixin
import confirm from './confirm';
export default {
mixins: [
confirm
],
methods: {
onDelete() {
this.confirm('Are you sure you wish to delete this item?').then(() => {
// Delete item
});
}
}
}
export default {
methods: {
confirm(message) {
return new Promise((resolve, reject) => {
confirm(message) ? resolve() : reject();
});
}
}
}
@clopezpro
Copy link

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment