Search code examples
vue.jsvuex

How execute a function inside a dialog?


i want to executing this function this.removeTheme(item) inside of my dialogModal

methods: {
deleteTheme(item){
this.$dialog
.confirm('Please confirm to continue')
.then(function(dialog) {
console.log('Clicked on proceed',dialog);
this.removeTheme(item)
})
.catch(function() {
console.log('Clicked on cancel');
});
},
...mapActions([
'removeTheme'
]),
},

but dont work what is the problem?


Solution

  • You should meet one context issue because of using function(){} for the callback.

    So using arrow function will fix the error.

    this.$dialog
    .confirm('Please confirm to continue')
    .then((dialog) => { // change function to arrow syntax
    console.log('Clicked on proceed',dialog);
    this.removeTheme(item)
    })