[Vuejs]-How to pass params of a 'delegated' function to another function from child to parents?

0👍

Actually I found a solution. Since you can use javascript inside VueJS templates, it just works with:

:pOnEdit="onEdit.bind(this, todos[idx].a, todos[idx].b)"

Then the grandparent has arguments of grandchild and child. I hope it helps if someone has the same question 🙂

1👍

Just use custom events

Inside click-to-edit component

<input @input="$emit('update', $event.target.value)" />

Parent:

<click-to-edit v-model="todos[idx].text" :editable="true" @update="$emit('update', $event, todos[idx].a, todos[idx].b)"></click-to-edit>

Grand parent:

<Parent @update="onUpdate" />
methods: {
  onUpdate(childArgument, parentArgumentA, parentArgumentB) {
   // do whatever
  }
}

Leave a comment