Hi @lstables,
I think you should be able to handle this without needing to use events. If you have a wire:model like you do but don’t pass a function pass a property (and make sure it’s an array). Then update your input to this:
<x-form-input
type="checkbox"
wire:model="completedTasks"
class="form-checkbox border-cool-gray-300 block transition duration-150 ease-in-out sm:text-sm sm:leading-5"
value="{{ $task->id }}
/>
Whenever that checkbox is selected that $task->id will be added to the $completedTasks array in your component. Then if you listen for changes to that element (your above code was slightly wrong. It was prefixed with update
not updated
.
Then add this to your component class:
public $completedTasks = [];
public function updatedCompletedTasks($value)
{
// Perform your update here. If you have multiple selected and only want to update the latest one you can compare $value against $this->completedTasks to find the new $task->id and update it.
}
You could also name your function updatingCompletedTasks if you wanted to perform the update before updating the UI.
Hope this was helpful?