نوافذ منبثقة قابلة لإعادة الاستخدام:
مكون النافذة
class ConfirmModal extends Component
{
public bool $show = false;
public string $title = '';
public string $message = '';
#[On('open-confirm')]
public function open($title, $message)
{
$this->title = $title;
$this->message = $message;
$this->show = true;
}
public function confirm()
{
$this->dispatch('confirmed');
$this->show = false;
}
}الاستخدام
<button wire:click="$dispatch('open-confirm', {title: 'حذف؟', message: 'هل أنت متأكد؟'})">
حذف
</button>
<livewire:confirm-modal />