Hi,
I am using a click event on buttons (component.blade):
<div class="columns">
@foreach($cards as $card)
<div class="column is-one-fifth">
<button wire:click="gotClicked('{{ $card->id }}')" style="width: 128px; height:128px; padding:0px;">
<img src="{{ $card->url }}">
</button>
</div>
@endforeach
</div>
Results in:
</div>
<div class="column is-one-fifth">
<button wire:click="gotClicked('afa4a0f24863c6308fcffc174f0a30d3')" style="width: 128px; height:128px; padding:0px;">
<img src="https://bulma.io/images/placeholders/128x128.xxx">
</button>
</div>
<div class="column is-one-fifth">
<button wire:click="gotClicked('f0e5793e81bf49ec2a2c34c4b4d52bd5')" style="width: 128px; height:128px; padding:0px;">
<img src="https://bulma.io/images/placeholders/128x128.xxx">
</button>
</div>
<div class="column is-one-fifth">
<button wire:click="gotClicked('5bbae843895fb3381ba1e641a7db500d')" style="width: 128px; height:128px; padding:0px;">
<img src="https://bulma.io/images/placeholders/128x128.xxx">
</button>
</div>
<div class="column is-one-fifth">
<button wire:click="gotClicked('90fc0042cc5cba5111f77b4123045601')" style="width: 128px; height:128px; padding:0px;">
<img src="https://bulma.io/images/placeholders/128x128.xxx">
</button>
</div>
The method that gets called:
public function gotClicked($card)
{
$bid = session('bid');
if($bid == $card){
dd('HURRAY!!!');
}
}
When I click on one of the buttons, the following error shows up:
Attempt to read property “id” on array
But when I put a dd() in the method like so:
public function gotClicked($card)
{
dd($card);
$bid = session('bid');
if($bid == $card){
dd('HURRAY!!!');
}
}
I get the value of $card
.
I don’t really get it and do not understand why it doesn’t work.
When I use {{ $card['id'] }}
it does not work at all. Because the ID do not get printed.
THX