[Vuejs]-Vue2 update parent scope from modal component

0👍

Well for one, you are setting a global variable app as a result of new Vue() and then you are blowing that variable away in your addNote method by setting app = this. That changes the variable to a completely different thing.

Also, you don’t show anything listening to the addingNote event.

Don’t use app everywhere. Use a scoped variable.

getNotes: function () {
    const self = this
    axios.get('/quality/ajax/get-notes/').then(function (response) {
        // populate notes
        self.notes = response.data.data.success[0].notes
    }).catch()
},

And change addNote.

addNote: function () {
   const self = this
   axios.get('/quality/ajax/add-note/', {
       params: { action: this.correctiveAction}
   }).then(function (response) {
       // append new corrective action
       self.$emit('addingNote', response.data.data.success[0].data);
       swal({
           title: "Boom!",
           type: "success",
           text: "Corrective Action Successfully Added",
       });
   }).catch()
}

Looks like you should also fix removeNote.

Leave a comment