Skip to content

the html vue is not correctly updated after change to the model performed inside a timeout #4648

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

Closed
lemmel opened this issue Jan 4, 2017 · 2 comments

Comments

@lemmel
Copy link

lemmel commented Jan 4, 2017

Hi.

I have a big structure data whose content changes dynamicaly, and in which I want to observe tiny variables.
For simplicity I made a code that is triggered on a click, code that call a timeout in order to be sure that all pending works (jquery, vue, and any others) are finished. In this timeout I change a boolean variable associated to a html checkbox.
So far, it seems that the html vue is not correctly updated after change to the model from the timeout call.

Vue.js version

2.1.8

Reproduction Link

In the provided code/example, after a click on the html checkbox a timeout (set to 5s) is called, in which the checkbox variable value is changed.

Here : http://codepen.io/anon/pen/BpaXze
The code:

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.1.8/vue.min.js"></script>
<div id='test'>
  <input v-model='checkbox' type="checkbox" v-on:click="click()">
  <BR>
  {{checkbox}}
</div>
<script>
var vm = new Vue({
  el: '#test',
  data: {
    checkbox: true
  },
  methods:{
    click: function(){
      window.setTimeout(function() {
          vm.checkbox = true;
        }
      , 5000)
    }
  }
})
</script>

What is Expected?

I expect the checkbox to be updated after setting its value.

What is actually happening?

The variable itself is correctly updated, but not the html checkbox.

@lemmel
Copy link
Author

lemmel commented Jan 4, 2017

Sorry: it seems that it is kind of duplicate of #4620. Mine is simpler ??!?

P.S. : I checked the bug tracker before this bug, and did not before filling my bug report. I do not closed this bug as the code is not exactly the same.

@lemmel
Copy link
Author

lemmel commented Jan 4, 2017

I double-checked and it is the same bug.
Thanks for all your work!

@lemmel lemmel closed this as completed Jan 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant