Defer on All Modal Fields?

I’ve recreated the data table from the Surge screencasts and have an edit modal with about 7 form fields. It seems that as I’m typing in any field, the table is refreshing in the background after every character sometimes.

If I add .defer to the wire:model for the field this behavior stops. My question is: Do I have to add wire:model.defer to each field individually or is there a better way to do this.

Thanks!

Hey, @rubendn

Use .lazy instead if you are using real time validation.

You can search all the words with wire:model=" in VSCode and replace them with wire:model.lazy=" or defer as you prefer.

P.S: take a look at Dirty State from the docs for more information.

Thanks. I’ll take a look at the difference between lazy or defer.

I was just wondering if there is a way that you apply lazy or defer to all the fields by applying it to a wrapping element or if applying it to each individual field is the proper way to do it.

Yup, I would prefer the second choice, because the implementation of the state depends on the situation, for example in some situation you need immediate result such as input search, and in other cases you don’t need that kind of faster response, Such as input validation and so on …