I'm creating an application using Aurelia, and in part of that application I have a grid that lists users, and specifically that users active status.
To allow the active state to be edited I've created a slide button control (Similar to those seen in iOS) where, sliding to the left is true, and to the right is false.
What I'd like to do is use this control in my user grid, so that people using it, can just click on the custom slide button to enable/disable the user, but I need that control to feed it's value when it changes back to the row it's placed in.
Something like this:
Imagine my table looks like this
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Is Active?</th>
</tr>
</thead>
<tbody>
<tr repeat.for="user of userList">
<td>${user.id}</td>
<td>${user.name}</td>
<td>${user.email}</td>
<td><slidebutton active="${user.active}"></slidebutton></td>
</tr>
</tbody>
</table>
This works great in so much that the slide button gets set to a default value based on the active status of the user as expected.
However when the slide button is changed, I would like for the row to be notified in someway, so that I can tell it to update the back end and change the status.
I'm not against passing in the user id to the custom component EG:
<td><slidebutton active="${user.active}" uid="${user.id}"></slidebutton></td>
But i'd rather not have the control make the call, or be doing anything that prevents me from using it in other places, such as on other grids that might have different items of toggle-able information.
I had thought of an event based way of doing it, then I looked at one of the user tables and saw there was a potential for a table with over 500 rows in it, and tracking/managing 500 events from 500 slide buttons didn't really seem like something I'd particularly want to do.
If there's a way of reflecting the value back into the attribute, then that I think would be a great start, but what I'd actually like if at all possible, is for the custom control to directly change the underlying view model on the row if at all possible.