@onurzdgn i think the issuue might be related to the fact that Livewire does not re-render the entire componeent on the second submmission and thus, the Livewire component's scripts are not being reloaded might be you must dispatczh an event after the flash message
Dec 10, 2023
3
Level 2
Livewire Error not Working Second Time
Hi everyone. I am using Laravel 10 and Livewire 3. I am trying to create success and error messages. It is working save with successful or error, it gives me error. However, when I try to save second time it not giving error. This is my livewire controller:
public function profilePassword()
{
$this->validate();
if (!Hash::check($this->password, auth()->user()->password)) {
session()->flash('message', ['I hope this time you give me correct password', 'Try again']);
$this->reset();
}
}
This is my error message:
@if (session()->has('message'))
@script
<script>
error();
function error() {
toastr.error("{{session()->get('message')[1]}}", "{{session()->get('message')[0]}}", {
positionClass: "toast-top-right",
timeOut: 5e3,
closeButton: !0,
debug: !1,
newestOnTop: !0,
progressBar: !0,
preventDuplicates: !0,
onclick: null,
showDuration: "300",
hideDuration: "1000",
extendedTimeOut: "1000",
showEasing: "swing",
hideEasing: "linear",
showMethod: "fadeIn",
hideMethod: "fadeOut",
tapToDismiss: !1
})
}
</script>
@endscript
@endif
This is my themes custom errors. Please ignore error messages these are not real.
Level 48
Please or to participate in this conversation.