From 38d74f081e41448eadc25fef676c99bc66700664 Mon Sep 17 00:00:00 2001 From: ariaieboy Date: Wed, 22 Nov 2023 00:06:29 +0330 Subject: [PATCH] fix --- resources/views/currency-mask.blade.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/resources/views/currency-mask.blade.php b/resources/views/currency-mask.blade.php index 647ed9d..949feb7 100644 --- a/resources/views/currency-mask.blade.php +++ b/resources/views/currency-mask.blade.php @@ -18,20 +18,20 @@ $xdata = <<this.updateInput()); - \$watch('masked',()=>this.updateMasked()); + \$watch('input',()=>this.updateMasked()); + \$el.addEventListener('input',(event)=>updateInput()); + \$el.addEventListener('blur',(event)=>updateInput()); }, updateMasked(){ - if(typeof this.input === 'numeric'){ - $el.value = this.input?.toString().replaceAll('.','$decimalSeparator'); - $el.dispatchEvent(new Event('input')); + if(typeof this.input === 'number'){ + \$el.value = this.input?.toString().replaceAll('.','$decimalSeparator'); + \$el.dispatchEvent(new Event('input')); } }, updateInput(){ - this.input = this.masked?.replaceAll('$thousandSeparator','').replaceAll('$decimalSeparator','.'); + this.input = \$el.value?.replaceAll('$thousandSeparator','').replaceAll('$decimalSeparator','.'); } } JS; @@ -77,9 +77,9 @@ class="fi-fo-text-input" 'readonly' => $isReadOnly(), 'required' => $isRequired() && (! $isConcealed), 'step' => $getStep(), - 'x-model' => 'masked', 'type' => 'text', 'x-data' => $xdata, + 'x-on:change'=>'updateInput', 'x-mask:dynamic' => $xmask ], escape: false) "