Good evening!
I would like to ask a question in terms of strange behaviour: when a wire:click action is triggered, another div on the same hierarchical layer seems to be removed/changed.
What seems to be the problem:
When a wire:click event is fired and the DOM of a element is replaced, the DOM of another element in a div below is somehow mixed up.
Steps to Reproduce:
-
Take the following code (blade view):
<div> <div> @if(App\User::find(1)->hasLiked(App\Question::find($question->id))) <button uk-icon="icon: check" wire:click="toogleLikeForUser({{ $question->id }})"></button> @else <button uk-icon="icon: heart" wire:click="toogleLikeForUser({{ $question->id }})"></button> @endif </div> <div> @if(App\User::find(1)->hasBookmarked(App\Question::find($question->id))) <button uk-icon="icon: bookmark" wire:click="toogleBookmarkForUser({{ $question->id }})"></button> @else <button uk-icon="icon: plus" wire:click="toogleBookmarkForUser({{ $question->id }})"></button> @endif </div> </div>
In the Livewire component, I have the following methods
public function toogleLikeForUser($questionId)
{
$user = \App\User::find(1);
$question = \App\Question::find($questionId);
$user->toggleLike($question);
}
public function toogleBookmarkForUser($questionId)
{
$user = \App\User::find(1);
$question = \App\Question::find($questionId);
$user->toggleBookmark($question);
}
Now when you click the button and toogle the icon to change, the other icon vanishes.
Are you using the latest version of Livewire:
Yes
Do you have any screenshots or code examples:
I am using Uikit (https://getuikit.com/docs/icon) for testing purposes.
Not sure if this is a bug of livewire, Uikit or me not knowing something
Thanks
Andreas