do you also have wire key on the table rows?
Rendering Livewire components inside a loop. Which is the correct way?
I'm doing an administrative page for users. The page loads User::all() and displays it. No big deal. Now I to create a filter for name or email that matches certain criteria. So my I have a loadData() function that goes
$this->users = User::where('name', 'like', '%' . $this->busqueda . '%')
->orWhere('email', 'like', '%' . $this->busqueda . '%')
->orderBy('id')
->get();
So far, so good, when user types something in the search box, the list is filtered. the <input> in the HTML is:
This works fine.
Now, a user can have one of serveral "levels" that define if the user is authorized, if is an admin, etc. So in this panel I want a to select the level. I tried this:
@foreach ($users as $user)
<x-gui.tr>
...
<td>
<livewire:admin.user.selectlevel :user="$user" :key="$user->id" />
</td>
...
</x-gui.tr>
@endforeach
The first time the page loads, it works perfectly, in the selectlevel component I have an unpdatedLevel() function that writes to the database, everithing works fine.
Now, if I filter the data, it stops working. The select shows for some rows and for some it doesn't. If I write something in the filter and then go back, it won't work either.
I got no idea what causes this, I don't know if it has to do with the rendering cycle, if I have to re-render the livewire component (I don't know how to do this), I don't know if the data that comes from the database renders slowly and I have to let it breathe, sort to speak (that's why I'm using the debounce), nothing seems to work for something as simple as this use case.
If using the select isn't the wiser thing, please advise how would you solve this
Thanks!
Please or to participate in this conversation.