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

Vue updating data before or after click event depending on browser #3139

Closed
loki0609 opened this issue Jun 22, 2016 · 3 comments
Closed

Vue updating data before or after click event depending on browser #3139

loki0609 opened this issue Jun 22, 2016 · 3 comments

Comments

@loki0609
Copy link

Vue.js version

v1.0.20

Reproduction Link

http://jsfiddle.net/5sH6A/468/

Steps to reproduce

Chrome/Firefox behave one way while IE 11/Edge behave a different way.

Chrome/Firefox - If you click on the check box changing it from a false to true state, vue DOES NOT update the row.selected value to true BEFORE the click event.

IE 11/Edge - If you click on the check box changing it from a false to true state, vue DOES update the row.selected value to true BEFORE the click event.

same thing going from true to false states

@yyx990803
Copy link
Member

Different browsers trigger change and click events in different orders, this is not something Vue can change nor is Vue responsible for normalizing this behavior. You should be listening to the change event instead of click.

@tibramo
Copy link

tibramo commented Jun 19, 2017

We solved this problem by wrapping our logic of the change-handler in Vue.nextTick. Then you always access the updated values.
Another solution could be a watcher on the property.

@stratboy
Copy link

Accepted answer should be Evan's one. That works in every case.

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

4 participants