Vue: Vue variable not updated.

Created on 17 Jul 2017  ·  10Comments  ·  Source: vuejs/vue

Version

2.4.1

Reproduction link

http://jsfiddle.net/vadvad/1pohLabg/22/

Steps to reproduce

Vue variable not updated after resive change message.

What is expected?

type = ok

What is actually happening?

type = not

Most helpful comment

I use jquery plugin in working project (select list, time, ...). Plugin make many operation and I want resive result from plugin by setting value to hidden input variable. This is clean and simply way to do this. If I work with vue you massege accepted, but this is not state. I must change value from jquery plagin and trigger vue to update this variable. This not work. Vue not update variable.

All 10 comments

Why using jQuery to do that? Did a quick fix to your fiddle:
http://jsfiddle.net/vadvad/1pohLabg/9/

Please see updated link
http://jsfiddle.net/vadvad/1pohLabg/22/

@vad11, v-model listens for input event to detect changes, doing something.value = 'new value' doesn't trigger input event.

Yes, but I send document.querySelector('input[name=type]').trigger('change') ;

@vad11 - you don't need and shouldn't use jQuery or document.querySelector when using Vue's v-model. All you have to do is the following: http://jsfiddle.net/1pohLabg/24/

I would recommend you read the Vue Guide, in particular Handling User Input. There might be some misunderstanding about how Vue should be used.

I use jquery plugin in working project (select list, time, ...). Plugin make many operation and I want resive result from plugin by setting value to hidden input variable. This is clean and simply way to do this. If I work with vue you massege accepted, but this is not state. I must change value from jquery plagin and trigger vue to update this variable. This not work. Vue not update variable.

Hi, thanks for your interest but Github issues are for bug reports and feature requests only. You can ask questions on the forum, the Discord server, gitter or StackOverflow.


Vue cannot listen back to setting the value directly into the DOM element

Please see https://github.com/vuejs/vue/issues/372 in bug reports. Writed that is solved, but I make this and for me this not work. May be this bug. I don't now. But please help me solve this problem.

I'm tryng to e2e with cypress and datetimepicker (vuetify). I setup an hidden input, triggered the change as expected, but the model doesnt get any update

Was this page helpful?
0 / 5 - 0 ratings