Hi,
i try to build an Toggle button between two payment plans.
This is the component:
class Shop extends Component
{
public $activePlan;
/**
* @return Application|Factory|View
*/
public function render()
{
$productData = (new CRMServiceHandler())->getProducts()->getResponse();
foreach ($productData['paymentCycles'] as $paymentCycle) {
if ($paymentCycle['picked'] === 1) {
$this->activePlan = $paymentCycle['id'];
break;
}
}
return view(
'livewire.shop',
[
'paymentCycles' => $productData['paymentCycles'],
'products' => $productData['products'],
]
);
}
}
And this is my blade File:
<div class="container">
<div class="mt-6 bg-gray-100 rounded-lg p-0.5 flex sm:mt-8">
<p>{{ $activePlan }}</p>
@foreach($paymentCycles as $paymentCycle)
<button type="button"
class="rounded-full py-3 px-6 border border-blue-primary"
wire:model="activePlan"
wire:click="$set('activePlan', {{ $paymentCycle['id'] }})"
>
{{ $paymentCycle['title'] }}
</button>
@endforeach
</div>
</div>
And this is my start blade
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Finde die beste Möglichkeit für dich</title>
<link href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@300;400;500;700&display=swap" rel="stylesheet">
<link href="{{ mix('css/app.css') }}" rel="stylesheet">
@livewireStyles
</head>
<body>
<livewire:navigation />
<livewire:shop />
<livewire:footer />
@livewireScripts
<script src="{{ asset('js/app.js') }}"></script>
</body>
</html>
So, i see the active Plan, i see to two Buttons, what is correct. But when i click on one of the Buttons the activePlan doesn’t change. There is no network activity too.
What do i wrong?
Cheers
Ralf