Full name calculation with afterStateUpdated
Hi. I use many inputs to calculate a name.
1. How can I abstract the function called in each afterStateUpdated to one function outside (sorry for this simple question)
2. Why I can't write the "Nombre" field? afterStateUpdated regenerates "fullname"
Thanks
6 Replies
Looks like an issue with live() you either need to provide a reasonable debounce or defer it to onBlur. Basically, it’s getting updated before the request can return a response from livewire. This will be better in v4 where you can offload it to JS instead of depending on a full livewire request.
Can I calculate the name BEFORE entering the fullname field?
Possibly, with the right alpine methods, but I don’t think it’s totally feasible at the moment.
Solution
My suggestion until v4 would be to use ->live(onBlur: true)
Then it would only get run when the field is blurred. Thus only one server request.
U rock dude