Trying to disable button after click not working

I have a button that I click to update a field in data base, but I want to limit the clicks to one time.

I tried jQuery or javascript but it does not work.

Please help me, I am new with livewire.

You can use some property that let the button change to “disabled” attribute. For example and using your code:

in blade
<button class... wire:click="updateReviewModal...." {{ $flag == 1 ? 'disabled' : '' }}></button>
in component
public $flag = 0;
public function updateReviewModal($value)
    //do your stuff
   $flag = 1; 

of course this is just an example, remember for this way when render the component again flag is going to be 0, so use other persistent logic for that…here is my idea. Hope this help you

Thank you very much, it worked :grinning:

1 Like