Eluknow's avatar

Using wire:click on a Laravel Blade component

Hi everyone,

I have just stumbled on a problem I don't manage to solve with Livewire and Blade components.

In fact, this code works :

<div>
    <x-steps-nav>
        @foreach ($tabs as $loop_tab)
            <li class="relative overflow-hidden lg:flex-1" wire:click="changeCurrentIndex('{{ $loop_tab }}')">
                <!-- .. -->
            </li>
        @endforeach
    </x-steps-nav>
</div>

Whereas this one doesn't work :

<div>
    <x-steps-nav>
        @foreach ($tabs as $loop_tab)
            <x-step-button :title="$loop_tab" :active="$loop_tab === $tab" :step="$loop->index" wire:click="changeCurrentIndex('{{ $loop_tab }}')">
            </x-step-button>
        @endforeach
    </x-steps-nav>
</div>

With this second code, the changeCurrentIndex is never called. I really don't understand what's the hell with this code... If someone can explain or finds where is a bug, it would be greatly appreciated !

Thanks in advance and have a good day guys ;)

0 likes
4 replies
CorvS's avatar
CorvS
Best Answer
Level 27

@eluknow How does your x-step-button component look like? Are you using the attribute bag there?

<button {{ $attributes }} ...>
6 likes
Eluknow's avatar

@corvs hello, thanks for your answer. My component didn't include any attribute bag. So I've just tested with the {{ $attributes }} and it works. I would have never thought about using the attributes bag but I understand. It makes sense now.

So, problem is solved. Thank you again @corvs ;)

1 like

Please or to participate in this conversation.