At the time confirm is called and the modal is show this.deleting is true. But if you expect that the vue component does some different rendering cause you changed this.deleting then no this won't happen, because confirm is blocking.
I would suggest to wrap the native dialog handling for confirm, alert, prompt into own function. That not only allows them to be opend/tiggered async, but also gives the possibility to replace them by custom dialog boxes later.
With await/async and Promises there is a nice way to do this:
you dialog module
const dlgs = {}
dlgs.confirm = function (message) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(confirm(message))
},0)
})
}
your vue component
<a
@click="destroy"
:class="['button', { 'is-loading': deleting }]"
>
Delete
</a>
data: () => ({
deleting: false
}),
async destroy () {
this.deleting = true
if (! await dlgs.confirm('Sure?') {
this.deleting = false
return
}
// do the deleting
}
Having custom dialog boxes that are implemented using html, have the advantage that you can update informations in background while the dialog box is opened.