alpine-mask icon indicating copy to clipboard operation
alpine-mask copied to clipboard

Two way data binding does not work

Open fredrickreuben opened this issue 2 years ago • 4 comments

I copy paste this <div x-data="{ raw: 2000 }"> <input x-mask.numeral x-mask:model="raw"> </div> from this link https://codetea.com/a-clean-integration-between-cleave-js-and-alpine/.

data property does not update, same as <div x-data="{ raw: 2000 }"> <input x-mask.numeral model="raw"> </div>

using Alpinejs v3.10.2

fredrickreuben avatar Jul 14 '22 10:07 fredrickreuben

Try using x-model instead of x-mask:model.

ryangjchandler avatar Jul 14 '22 11:07 ryangjchandler

Hey, I ran into the same issue with Alpinejs v3.8.

Does not format the value (2000)

<div x-data="{ raw: 2000 }">
      <input x-model="raw" x-mask.numeral >
</div>

Does format the value (3,000)

<div x-data="{ raw: 2000 }">
       <input value="3000" x-mask.numeral >
</div>

iambateman avatar Aug 02 '22 02:08 iambateman

What if I want to disable this?

jgauna avatar Aug 26 '23 04:08 jgauna

@fredrickreuben I ran into the same issue with Alpine.js 3.10.2. After investigating, I found it due to alpine.js loading x-mask before x-model. https://github.com/alpinejs/alpine/releases/tag/v3.10.2

  • Broke it: https://github.com/alpinejs/alpine/pull/2857/commits/579fc43a71276a3127850f3104ed03cc8394765e
  • Fixed it: https://github.com/alpinejs/alpine/commit/c31d62e853147ca436336c1098f1a820ae2fe195

clyer avatar Dec 12 '23 02:12 clyer