Skip to content

Commit

Permalink
Passing extra parameters to alert events (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
jantinnerezo authored Nov 9, 2021
1 parent d904406 commit 3f955ec
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion public/livewire-alert.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions resources/js/livewire-alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
window.addEventListener('alert', async (event) => {
var message = event.detail.message;
var icon = event.detail.type ?? null;
var data = event.detail.data;
var events = event.detail.events;
var options = event.detail.options;

Expand All @@ -15,9 +16,15 @@ window.addEventListener('alert', async (event) => {
confirmed: alert.isConfirmed,
denied: alert.isDenied,
dismiss: alert.dismiss,
result: alert,
...alert,
result: {
...alert,
data: {
...data,
inputAttributes: options.inputAttributes ?? null
}
},
...events,
...alert,
...options
})
});
Expand All @@ -34,7 +41,13 @@ window.flashAlert = async (flash) => {
confirmed: flashAlert.isConfirmed,
denied: flashAlert.isDenied,
dismiss: flashAlert.dismiss,
result: flashAlert,
result: {
...flashAlert,
data: {
...data,
inputAttributes: options.inputAttributes ?? null
}
},
...events,
...flash.options
})
Expand Down
Loading

0 comments on commit 3f955ec

Please sign in to comment.