I am new in laravel livewire. I am trying to toggle a modal using livewire. For that I have taken a variable name $isOpenModal
. Initially it is false. When I click a radio input the value of $isOpenModal
turn to true using $set('isOpenModal','true')
. It opens the modal succesfully. When I click the close button I tried to close the modal using $set('isOpenModal','false')
. But this is not working.
Here is my code
<div class="w-2/5 p-1 text-center " wire:click="$set('isOpenModal', 'true')">
<label class="labl">
<input type="radio" name="radioname" value="one_value"/>
<div class="rounded-lg py-2 px-3">{{trans('strings.change')}}</div>
</label>
</div>
<div class="d-flex justify-content-center align-items-center" >
<button wire:click="$set('isOpenModal', 'false')">
<div class="btn btn-danger">
<span class="text-base text-white-400 hover:text-white-300">{{trans('strings.close')}}</span>
</div>
</button>
</div>
How do I pass false value in the $set method
. I have tried passing 0 and It's works . But I need to work with boolean
you are passing 'true' / 'false' as string. pass it without ' '.
like this
wire:click="$set('isOpenModal', true)"
Hope it helps. let me know
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With