Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't programmatically change the value with Vuetify #44

Open
talski opened this issue Dec 5, 2017 · 28 comments
Open

Can't programmatically change the value with Vuetify #44

talski opened this issue Dec 5, 2017 · 28 comments
Assignees
Labels

Comments

@talski
Copy link

talski commented Dec 5, 2017

When using with Vuetify, I can't reset the model value

https://codepen.io/talski/pen/MOxZXX?editors=1010

@neves
Copy link
Member

neves commented Dec 5, 2017

I'll check it.

@neves neves self-assigned this Dec 5, 2017
@neves neves added the bug label Dec 5, 2017
@lchhieu
Copy link

lchhieu commented Dec 17, 2017

same issue

@evandroabukamel
Copy link

evandroabukamel commented Jan 25, 2018

I'm having the same problem.

I put v-money inside another component. When I try to programmatically change the value on the v-model of the parent component, the v-money keeps the old value.

[FIXED] I was using a this.$nextTick without need to change the child component value.

@luizhenriquerdias
Copy link

Same here. Any update?

@rafaellarrosa
Copy link

Same here...

@rafaellarrosa
Copy link

the problem is with v-text-field, with input works good

@kevinfaveri
Copy link

kevinfaveri commented Mar 14, 2018

Same here... but I'm using ElementUI (element.eleme.io)

@kevinfaveri
Copy link

kevinfaveri commented Mar 14, 2018

While there is no solution, pure Javascript can be used to set the input value and then create an 'Input' event, which is the event that the 'v-model' directive listens to:
domInputElement.value = newValue;
domInputElement.dispatchEvent(new Event('input'));

@johnleider
Copy link

We are currently in the process of updating all form components for v1.1. If you can fix the codepen to produce the issue, I can verify it against our latest work.

@paulpv
Copy link

paulpv commented Apr 4, 2018

@johnleider What do you mean "If you can fix the codepen to produce the issue"?
The original codepen (https://codepen.io/talski/pen/MOxZXX?editors=1011) produces the issue and doesn't log any console errors.
I have a slight variant of the original code pen that uses an array of prices instead of a single price:
https://codepen.io/paulpv/pen/oqMeXd

@johnleider
Copy link

I must of been looking at something incorrectly, thanks @paulpv

@paulpv
Copy link

paulpv commented Apr 4, 2018

@johnleider NP; I am certain you are busy!

@mukatk
Copy link

mukatk commented Apr 14, 2018

I saw a workaround somewhere and the same solution works to Vuetify

https://codepen.io/mukatk/pen/NYZvPW

@luizhenriquerdias
Copy link

I made a directive based on v-money that works with Vuetify (v-text-field) and normal inputs.
Note: I made it to work with Brazilian Real (R$) but you can change in the code.

https://github.com/luizhenriquerdias/v-money

@MartinX3
Copy link

in my e2e tests with selenium / chromedriver I saw the same issue.
With nightwatch and gebish.
The new value gets appended to the old one.

@averied
Copy link

averied commented Sep 3, 2018

This plugin breaks reactivity of inputs after adding the v-money parameter. I'm using v-model binded to vuex state.

@KaelWD
Copy link

KaelWD commented Oct 15, 2018

v-model.lazy doesn't work on components, you have to listen to @change yourself: https://codepen.io/anon/pen/BqmBjb?editors=1010

vuejs/vue#6914

Edit: the mask then breaks after resetting the input, so there's still a bug somewhere

@luizrobertomeier
Copy link

Just one more option :
https://www.npmjs.com/package/v-currency-field

@Nerossoul
Copy link

I'm having the same problem.

I put v-money inside another component. When I try to programmatically change the value on the v-model of the parent component, the v-money keeps the old value.

[FIXED] I was using a this.$nextTick without need to change the child component value.

Can you show how to use a this.$nextTick to change v-money value?

@MartinX3
Copy link

MartinX3 commented Feb 15, 2019

Any update on this?

Edit:
For NightwatchJS this seems to be a good approach:
nightwatchjs/nightwatch#1132 (comment)

@danielorkae
Copy link

same here

@valterbarros
Copy link

@kevinfaguiar Your solution work for me I'm using v-money and vuetify

@RodrigoFraga
Copy link

workaround solution
https://gist.github.com/RodrigoFraga/49cf179c3fdf5c6f775450b613137bd3

@yvescavalcanti
Copy link

Same problem with bootstrap-vue when i try to extend Money. If i try to set the value programatically then it is restored to previous value.

@ElizeuBraga
Copy link

ElizeuBraga commented Sep 22, 2020

<v-text-field maxlength="10" v-money="money" ref="productPrice" label="Product price" v-model="productPrice"></v-text-field>
const input = this.$refs.productPrice.$el.querySelector("input");
input.value = "new value";`

this works for me

@Adrug
Copy link

Adrug commented Feb 24, 2021

I can't reset for native input also.
https://jsfiddle.net/nj3cLoum/2/

@jonathanpmartins
Copy link

hey,
Unfortunately I don't think support will come soon. This repo seems to be abandoned! I decided to upgrade this package to be used with Vue3.

Welcome v-money3!

I'm interested to maintain v-money3 for vue 3 and beyond. Feel free to open this same issue there if you are planning to upgrade your project.

@1985michel
Copy link

1985michel commented Apr 29, 2022

Hi!

I did a watch using the @ElizeuBraga solution and it's working very well:

<v-text-field
        ref="valormascarado"
        outlined
        v-model="editedItem.valor"
        v-money="money"
        label="Valor"
></v-text-field>

watch:{
editedItem() {
      let input = this.$refs.valormascarado.$el.querySelector("input");
      input.value = this.editedItem.valor;
    },
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests