Skip to content

Commit

Permalink
Add example on how to pass multiple attributes to event (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuvroroy authored Apr 3, 2021
1 parent e5332ec commit badf17d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ To open the `EditUser` modal for a specific user we can pass the user id (notice

```html
<!-- Outside of any Livewire component -->
<button onclick='Livewire.emit("openModal", "edit-user", @json(['user' => $user->id]))'>Edit User</button>
<button onclick='Livewire.emit("openModal", "edit-user", @json(["user" => $user->id]))'>Edit User</button>

<!-- Inside existing Livewire component -->
<button wire:click='$emit("openModal", "edit-user", @json(['user' => $user->id])'>Edit User</button>
<button wire:click='$emit("openModal", "edit-user", @json(["user" => $user->id])'>Edit User</button>

<!-- Example of passing multiple parameters -->
<button wire:click='$emit("openModal", "edit-user", @json([$user->id, $isAdmin])'>Edit User</button>
```

The parameters are passed to the `mount` method on the modal component:
Expand Down

0 comments on commit badf17d

Please sign in to comment.