[Vuejs]-Vue2 – call method from main instance inside component

0👍

What you are looking for is called event bus, you can create it to fire parent events from children events.

It should go props down, events up (down being parent to child).

In your case, something like:

const EventBus = new Vue();

on your child component:

@click="$bus.$emit('deleteMultiple')"

and in the parent:

created () {
    this.$bus.$on('deleteMultiple', ($event) => {
        this.deleteMultiple();
    })
  }

There are lot of tutorials over internet on differents types of bus and plugins like this: https://medium.com/@andrejsabrickis/https-medium-com-andrejsabrickis-create-simple-eventbus-to-communicate-between-vue-js-components-cdc11cd59860 or http://vuetips.com/global-event-bus

Hope it helps!

Leave a comment