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
Force v-model to update its value? #1136
Comments
@patrick-hertling I don't think this should be solved by vue, but rather by the external library you are using. With jQuery-stuff you should |
Thank you. I think I will use a directive. |
How do we use two way directives ? i tried, using |
I'm having this issue while testing a Vue controlled form with Selenium. When running the Selenium tests Vue doesn't catch the changes. I wonder if there is a method to refresh the whole dataset from the view. |
@markskayff i found this way: |
I am facing the same issue. |
If you set properties on an element imperatively, you need to dispatch a native event to force bound data to update: const event = new Event('input')
vm.$refs.child.value = 'something'
vm.$refs.child.dispatchEvent(event) Different elements need different event types:
|
@eddyerburgh, I tried your solution but it's not working in my scenario. i am getting this error- |
@eddyerburgh Thank you, your way is a good solution to Input element, but it seems not working with the image element. I got some images they bind to different data, but they also bind to the same function. And I do not want to bind value using if-else branch。 <img :src="d.A" @click="fn" />
...
<img :src="d.Z" @click="fn" />
fn(e) {
// this is it should be
e.target.src = 'some-address'
// this is just not good
if(xxxx) d.A = 'xxxx'
...
else d.Z = 'xxxx'
}
|
Wrap the native textField component in a custom component, add a watcher for the changing property, in the watcher call the forceUpdate() function to re-render the component. TS texample:
|
Sometimes you have a textfield set up as v-model which can change due to an external javascript process(like a datepicker).
In those cases, the 2-way-binding of the v-model doesn't gets fired. Is there a way of forcing Vue to fetch the actual value of his binding(In case it had changed and Vue didn't notice).
The text was updated successfully, but these errors were encountered: