Closed aliqasemzadeh closed 2 years ago
What do you think about modal ajax? Describe more about "ajax modal"
@PH7-Jack Hi For example load data from another component base on button click.
@PH7-Jack For Example:
<x-modal blur fullscreen wire:model.defer="panelModal">
<x-card fullscreen>
<livewire:panel symbol="???" >
</x-card>
</x-modal>
While symbol will change base on onclick="$openModal('panelModal')"
When modal is opening, the livewire component receives a value?
@PH7-Jack Yes exactlly.
@PH7-Jack Can you guide me how to do it?
I believe this cannot be done, the variables passed in the livewire component are not reactive. But it is possible to do this using livewire events.
Create a listener into your component to receives and set the new value Before opening a modal, send an event with a new value to set
Ex:
Outside component
public function openModal() {
$this->modal = true;
$this->emit('set-value', $newValue);
}
Component Inside Modal
protected $listeners =['set-value' => 'setValue'];
public function setValue($value) {
$this->myVar = $value;
}
I think this can be closed
I will go move it to one discussion, if the events solve the problem, I will mark it as complete
Hi I think we can have ajax modal