[英]How can we apply real time validation in laravel using livewire, if we are using wire.model.defer on input?
[英]Defer updating [wire:model.defer] not working for a textarea input within a modal in Laravel Livewire
所以我使用的是 Livewire 2.10.4,我在模態中有一個文本區域,如下所示:
<div
x-data="{
showDiscontinueModal: @entangle('showModal')
}"
>
<x-modal x-model="showDiscontinueModal" modalDialogClasses="modal-sm-md">
<x-slot name="content">
<x-input.group class="w-full">
<x-input.label>{{ trans('rx.pharmacy_notes') }}</x-input.label>
<x-input.textarea
wire:model="pharmacyNote"
/>
</x-input.group>
</x-slot>
</x-modal>
</div>
textarea 刀片組件如下所示:
@aware(['error'])
@props(['error' => null])
<textarea
type="text"
x-bind:id="$id('input')"
{{ $attributes->class([
'form-input',
'form-control',
'missing' => $error,
]) }}
></textarea>
但是每次用戶在文本區域輸入字段中輸入內容時,Livewire 會水合,導致輸入中出現許多不必要的請求和奇怪的行為(它會閃爍並刪除正在輸入的部分內容)
到目前為止,我嘗試使用wire:model.defer
、 wire:model.lazy
和wire:model.debounce
來嘗試減少請求數量,但出於某種原因,這根本不會影響行為。 我還測試了將字段更改為簡單的文本輸入,但也沒有用。
嘗試wire:ignore
或wire:ignore.self
作為你的 textarea parent
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.