I would like to pass this method of the parent component to the child component, let me explain: when I click the confirm button on my modal (child component) it must send the data of the parent form (parent component)
the method of parent component:
<b-form @submit.prevent="onSubmit">
.......
</b-form>
async onSubmit() {
this.errors = false;
await this.$store.commit('commit_contractable_id', this.id)
await this.$store.dispatch('create_contract', this.form)
},
my modal of child component button:
<button type="submit" class="btn btn-lg btn-outline-primary w-50" data-dismiss="modal">
Confirm
</button>
i want when i click confirm executes the function that is in the parent component
onSubmit. Here is vue docs. In your child component you can usev-on:click="$emit('modal-submit')"and in the parent componentv-on:modal-submit="onSubmit". You can also pass form data with$emitand then get that data in the parent. Check the docs example