i want to show a dialog box before deleting a files, how i can do it with vue?
here what i try
my button to delete a file
<a href="javascript:;" v-on:click="DeleteUser(artist.id, index)" onClick="return confirm('are you sure?');">Delete</a>
and here my delete method
DeleteUser(id, index) {
axios.delete('/api/artist/'+id)
.then(resp => {
this.artists.data.splice(index, 1);
})
.catch(error => {
console.log(error);
})
},
the dialog is showing but whatever i choose it keep delete the file.
Try this
Simply use
if(confirm('are you sure?'))
insideDeleteUser
.and remove the
onClick
Demo https://jsfiddle.net/jacobgoh101/ho86n3mu/4/