0👍
export default {
props:['service', 'method', 'id'],
methods: {
destroy() {
var self = this;
swal({
title: 'Weet u het zeker?',
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Ja verwijder',
cancelButtonText: 'Stop!',
confirmButtonColor: '#34495e',
cancelButtonColor: '#ff3860',
}).then (() => {
self.service[self.method](self.id)
.then(() => {
swal({
title: 'Verwijderd',
text: 'Succesvol verwijderd',
type: 'success',
showConfirmButton: false,
timer: 2000
});
location.reload();
})
.catch(() => {
swal({
title: 'Fout',
text: 'Heeft u voldoende rechten?',
type: 'error',
showConfirmButton: false,
timer: 2000
});
});
})
}
}
}
You should create global link to “this” variable, in SWAL callback function “this” is replaced by local SWAL var.
Source:stackexchange.com