Created
November 10, 2018 19:37
-
-
Save martinbean/4469b5a44757a1ed7b1fd38eeb8a23c8 to your computer and use it in GitHub Desktop.
Promise-based Vue.js confirmation dialog mixin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import confirm from './confirm'; | |
export default { | |
mixins: [ | |
confirm | |
], | |
methods: { | |
onDelete() { | |
this.confirm('Are you sure you wish to delete this item?').then(() => { | |
// Delete item | |
}); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
methods: { | |
confirm(message) { | |
return new Promise((resolve, reject) => { | |
confirm(message) ? resolve() : reject(); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks