hi
i have a x-data in my div with alpinejs
and i whant to pass the object to livewire
what is the best and simple way to do that??
thanks
hi
i have a x-data in my div with alpinejs
and i whant to pass the object to livewire
what is the best and simple way to do that??
thanks
Hey @haiibooo,
there are several ways to do this.
You can use “wire:model” and dispatch an “input” event from within AlpineJS. That way livewire will update your PHP “model” whenever a new “input” event is dispatched.
As you are in a Livewire Component you can use “@this.set(‘PHPVariableName’, ‘DATA’)” to manually set a variable within your Livewire component to what you have in your AlpineJS instance.
When possible i would prefer option number 1. But that’s up to you.
See for reference: https://laravel-livewire.com/docs/alpine-js#communicating-with-js
Hope i could help!
thanks
but i need to pass data after i do customizeing my object that i whan to pass with alpine JS
I‘m not sure if i get you right, but with the options i provided it is/should be possible.
Can you give us an example of what your exact problem is?
Just determine in x-data of Alpine the variable with @entangle(‘name the variable in component’)…