I have a simple parent component and child component...
<script setup>
import ChildComponent from "...";
function onAdd(){
...
}
</script>
<template>
<ChildComponent></ChildComponent>
<template>
<script setup>
function doSomething(){
// call onAdd
}
</script>
<template>
<div>
<div @click="doSomething></div>
</div>
</template>
What I would like to do is call onAdd from the child component. How would I go about doing this?
I tried this (sorry changed from onAdd to refreshRecords)...
//Parent
<script setup>
async function refreshRecords() {
console.log("Refreshing");
}
</script>
<template>
<Child :refresh-records="refreshRecords"></Child>
</template>
// Child
<script setup>
const emits = defineEmits(['refresh-records']);
async function onSubmit(){
...
console.log("Emitting");
emits('refresh-records', {});
}
</script>
<template>
<q-form @submit="onSubmit" class="q-gutter-md" >
...
<q-btn label="Submit" type="submit" color="primary" />
</q-form>
</template>
The refresh never gets called but I see the Emitting message