2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Laravel Livewire model:clickの前にJS comfirmしたい

Last updated at Posted at 2022-04-21

Laravel Livewireでwire:clickを使うと、clickイベントが起きると即座にfunctionが実行されてしまう
ので、onclickでJSを呼び出してemitでfunctionを呼び出す・・ってやらなきゃいけないかと思ってたけど
ぐぐったら以下の記事を発見

どうもonclickの後にwire:clickが呼び出される順番になっているようですね。
で、event.stopImmediatePropagation()と組み合わせることで、それ以上のイベントを抑制することが
できるということですごく便利です。

<button onclick="confirm('削除を実行しますか?') || event.stopImmediatePropagation()" 
		wire:click="delete_object">削除!</button>
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?