F
Filament15mo ago
Omar

How can I refresh a widget so that the variable that I send to it is updated?

I am trying to update a variable that is in the custom page where my widget is rendered but I would have to refresh the widget but it doesn't work for me. this would be my widget component
protected $listeners = ['refreshComponent' => '$refresh'];
public $form_selected = [];
protected function getOptions(): array
{
if($this->form_selected){
dd($this->form_selected);
}
}
protected $listeners = ['refreshComponent' => '$refresh'];
public $form_selected = [];
protected function getOptions(): array
{
if($this->form_selected){
dd($this->form_selected);
}
}
and this is my page component
public $form_selected = [];
public function toggleModal($form)
{
$this->form_selected = $form;
$this->emit('refreshComponent');
}
public $form_selected = [];
public function toggleModal($form)
{
$this->form_selected = $form;
$this->emit('refreshComponent');
}
No description
2 Replies
krekas
krekas15mo ago
You are on v3?
Omar
OmarOP15mo ago
on v2
//custom page
public function loadChart($form){
$this->emit('refreshChart', $form);
$this->emit('refreshComponent');
}

//chart
protected $listeners = ['refreshChart' => 'refreshChart' , 'refreshComponent' => '$refresh'];
public function refreshChart($form_selected)
{
$this->form_selected = $form_selected;
}
//custom page
public function loadChart($form){
$this->emit('refreshChart', $form);
$this->emit('refreshComponent');
}

//chart
protected $listeners = ['refreshChart' => 'refreshChart' , 'refreshComponent' => '$refresh'];
public function refreshChart($form_selected)
{
$this->form_selected = $form_selected;
}
this worked for me
Want results from more Discord servers?
Add your server