Scenario
I have a generic modal component, where i use a global bus (empty VUE instance), to communicate with the modal component from whichever other component that's using it..
Issue
in the Mounted() or Created() hook for the Modal.VUE component, i'm trying to overwrite the default initialized value i need to figure out which content is to be displayed in the modal.
console.log("Selected action is : " + actionName)
... prompts out the correct actionName, so the bus functionality is there..
But when setting the variable like this :
this.modalComponent == actionName
.. and using it like this :
<h2 v-if="modalComponent == 'refund'">Refundér</h2>
<h2 v-if="modalComponent == 'empty'">Not defined</h2>
.. the modalComponent value is always empty (as initialized)
Script code :
<script>
import bus from '../global/bus.js'
export default {
name: "modal",
data(){
return {
modalComponent: "empty"
}
},
mounted() {
bus.$on('on-action', function (actionName) {
console.log("Selected action is : " + actionName)
this.modalComponent == actionName
})
}
}
So what am i doing wrong here ? is it the way i'm initializing ? Is it a problem with the mounted() or created() hook ? Or.. the way i'm setting the new value ?