In Livewire 2, I could postpone the update by sending the value true in the last parameter, but this possibility is not available in Livewire 3.
What is the alternative for @this.set('prop', value, true) in livewire 3 ?
In livewire 3 you should wrap your <script></script> in @script <script></script> @endscript. This will give you access to the $wire variable to access your component.
Ref: https://livewire.laravel.com/docs/components#using-javascript
Ref: $wire object: https://livewire.laravel.com/docs/javascript#the-wire-object
Then refactor your @this.set('prop', value, true) to $wire.set('prop', value, true). Note that true is the default value for 'defer' when using set(). Setting it to false has a different effect in the end.
Try to use livewire js events On your js file:
const isEnabled=true;
Livewire.emit('dataChanged',isEnabled);
On component php class
protected $listeners = ['dataChanged' => 'dataChanged'];
public $isEnabled;
public function dataChanged($data){
$this->isEnabled=$data;}
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