Skip to content

Commit

Permalink
Merge pull request #22 from ariaieboy/test
Browse files Browse the repository at this point in the history
refactor the currency mask to use native alpine x-model
  • Loading branch information
ariaieboy committed May 14, 2024
2 parents 8523166 + dbc207b commit b952e70
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions resources/views/currency-mask.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
$xdata = <<<JS
{
input:\$wire.{$applyStateBindingModifiers("\$entangle('{$statePath}')")},
masked:'',
init(){
\$el.value = this.input?.toString().replaceAll('.','$decimalSeparator');
this.masked = this.input?.toString().replaceAll('.','$decimalSeparator');
\$watch('masked',()=>this.updateInput());
\$watch('input',()=>this.updateMasked());
\$el.addEventListener('input',(event)=>this.updateInput());
\$el.addEventListener('blur',(event)=>this.updateInput());
},
updateMasked(){
if(typeof Number(this.input) === 'number'){
Expand Down Expand Up @@ -79,7 +79,7 @@ class="fi-fo-text-input"
'step' => $getStep(),
'type' => 'text',
'x-data' => $xdata,
'x-on:change'=>'updateInput',
'x-model'=>'masked',
'x-mask:dynamic' => $xmask
], escape: false)
"
Expand Down

0 comments on commit b952e70

Please sign in to comment.