Level 122
why use flash?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I add this alpine code x-data="{show: true}" x-init="setTimeout(() => show = false, 5000)" x-show="show">
to close session flash after adding, updating data but when I insert additional record the flash is not firing and I need to refresh the browser first.
full code
@if (session()->has('success') )
<div class="alert alert-success alert-block" x-data="{show: true}" x-init="setTimeout(() => show = false, 5000)" x-show="show">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>{{ session('success') }}</strong>
</div>
@endif
@Snapey I solved it :)
Livewire.hook('message.processed', (component) => {
setTimeout(function() {
$('#alert').fadeOut('fast');
}, 300);
});
Please or to participate in this conversation.