#Dispatch event from afterStateUpdated to another field?

3 messages · Page 1 of 1 (latest)

mortal tapir
#

Hey guys, I have a builder field with a afterStateUpdated function where I want to dispatch the current value to a custom field. I tryed livewire listener but this didnt worked.

Is this possible? Or could I force a rerender of the custom field by manipulating its state?

Thanks.

Builder::make('content')
->blocks(
PageBlocks::make())
->live()
->afterStateUpdated(function(Get $get, Set $set, Livewire $livewire) {
  $livewire->dispatch('updateData', $get('content'));
  $set('preview', $get('content'));
}),
    #[On('updateData')]
    public function updateData(array $data)
    {
        dd($data);
    }
hexed foxBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

gleaming tangle