mercredi 25 octobre 2017

How can I collect selected checkboxes from all child checkbox components in vue?

I have a table where the row elements are all populated by child components. There is a checkbox in each of these child components. Now I want to get all checked checkboxes at once. I could use prefs emit as two way binding and update an array or object on the parent but I am wondering if there is better way for this.

Here a short example for the template part:

<table>
    <thead>
        <tr>
            <th> Check </th>
            <th> Title </th>
        </tr>
    </thead>
    <list-tbody v-for="element in elements" :element="element"> </list-tbody>
</table>

and this is the child component

<tbody>
    <tr>
        <td>
            <input type="checkbox">
        </td>
        <td>  </td>
    </tr>
</tbody>




Aucun commentaire:

Enregistrer un commentaire