Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

anonymouse703's avatar

Session flash not firing/displaying when adding additional record.

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
0 likes
3 replies
anonymouse703's avatar
anonymouse703
OP
Best Answer
Level 6

@Snapey I solved it :)

Livewire.hook('message.processed', (component) => {
            setTimeout(function() {
                $('#alert').fadeOut('fast');
            }, 300);
        });

Please or to participate in this conversation.