We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello, perhaps in the next version, a function similar to the one I wrote yesterday could be added:
namespace App\Traits; use Jantinnerezo\LivewireAlert\LivewireAlert; use Livewire\Attributes\On; /** * Class Helper. */ trait Helper { use LivewireAlert; public function confirmMethod($method, $title, $text = null, $id = null){ $this->confirm($title, [ 'onConfirmed' => 'runMethod', 'data' => [ 'idFromConfirm' => $id, 'confirmMethod' => $method ], 'text' => $text, ]); } #[On('runMethod')] public function runMethod($data){ $id = $data['idFromConfirm']; $methodName = $data['confirmMethod']; if($id === null){ $this->{$methodName}(); } else { $this->{$methodName}($id); } }
How to use it in Blade?
<button wire:click="confirmMethod('delete', 'Do you want to delete?', '', $id)" >Run function</button>
This will execute $this->delete($id)
$this->delete($id)
No need to use protected $listeners = ['delete']; or #[On('delete')]
protected $listeners = ['delete']; or #[On('delete')]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hello, perhaps in the next version, a function similar to the one I wrote yesterday could be added:
How to use it in Blade?
This will execute
$this->delete($id)
No need to use
protected $listeners = ['delete']; or #[On('delete')]
The text was updated successfully, but these errors were encountered: