Santosh Khanal
Santosh Khanal

Reputation: 33

Laravel Livewire only ping to server on form submit

I am learning livewire, and recently tallstack.dev to discover its possibility.

One thing I noticed is livewire will ping to server and sync the wire:model variables with backend.

In some cases, like when we register a user, or while login, we may have few input fields.

And we may just use wire:model.lazy to only trigger sync to server when focus out of the input.

The main issue here is, there is no need to sync/ping to server the current value the user has typed on one of the input fields, as the whole form is not complete still.

So whenever I hit tab or click away to another field, it syncs to server.

And at last before I click on submit, it still will ping the server one last time, as it also lose focus from the input.

So if I have 5 input fields on my register form, from the first field fill up to submit button click, there will be 6 ping to the server.

Is there a way to just wire:model and only send all input values at once on submit click?

Upvotes: 2

Views: 1384

Answers (1)

bnqtoan
bnqtoan

Reputation: 799

You can use wire:model.defer

FYI: https://laravel-livewire.com/docs/2.x/properties#deferred-updating

Upvotes: 2

Related Questions