niksmr / vue-masked-input

Masked input component for Vue.js
https://niksmr.github.io/vue-masked-input/
MIT License
454 stars 92 forks source link

Changing the object doesn't update the input #39

Closed ghost closed 6 years ago

ghost commented 6 years ago

Updating the object passed by v-model, the masked input stills empty.

ghost commented 6 years ago

Nevermind, was my mistake. Sorry about the issue.

vovek commented 6 years ago

@noamcore Hi, could you tell what was a a mistake? I have the same issue, data which is loaded from store not masked.

ghost commented 6 years ago

Sorry @vovek, I can't remember in what project was this issue.

If you create a snippet maybe I can help you.

k-zakhariy commented 6 years ago

@vovek same issue for me, didn't find reason

k-zakhariy commented 6 years ago

Found solution

//number format - 380931231231
created: function () {
            this.$store.dispatch("loadAuthUser", {
                withScope: ['addresses'],
            }).then(()=>{
                let phone = this.currentUser.phone;
                this.order = {
                    ...this.order,
                    firstname: this.currentUser.firstname,
                    lastname: this.currentUser.lastname,
                    phone: phone.replace(/38(\d{3})(\d{3})(\d{2})(\d{2})/, "+38 ($1) $2-$3-$4"),
                }
            });
        }