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

[md-select] v-model in @md-selected returns previous value #1275

Closed
zapping opened this Issue Dec 7, 2017 · 8 comments

Comments

Projects
None yet
3 participants
@zapping
Copy link
Contributor

zapping commented Dec 7, 2017

If you try to get the value of v-model in the @md-selected event of md-select then it always shows the previous value and not the current selected one.

Is it possible to get the current value of v-model like in the @change event of select in vuejs?

@Samuell1

This comment has been minimized.

Copy link
Member

Samuell1 commented Dec 7, 2017

Do you using 1.0.0-beta7 version? I tested it and its working normally.

@Samuell1 Samuell1 added the needs repro label Dec 7, 2017

@zapping

This comment has been minimized.

Copy link
Contributor Author

zapping commented Dec 7, 2017

Its 1.0.0-beta7

@Samuell1

This comment has been minimized.

Copy link
Member

Samuell1 commented Dec 7, 2017

Can you please provide example at codepen or your code?

There is gif i tested it with multiple select
2017-12-07_09-17-23

@zapping

This comment has been minimized.

Copy link
Contributor Author

zapping commented Dec 8, 2017

The md-select is not a multiple one but a single value select.

https://codepen.io/zapping/pen/yPdKvW

This issue, #1262, exists for me as well when rendering from backend service.

@VdustR

This comment has been minimized.

Copy link
Member

VdustR commented Dec 8, 2017

In your case,

mdSelected () {
  this.paymentMode = this.paymentModes;
  console.log(this.paymentModes);
}

this.paymentModes would be changed on the next tick (it's next x2 actually), you should change it to:

mdSelected (val) {
  this.paymentMode = val;
  console.log(val);
}

and your would get the right value.

updated: This event should be emitted after the value changed.

VdustR added a commit to VdustR/vue-material that referenced this issue Dec 8, 2017

@VdustR VdustR added bug and removed needs repro labels Dec 8, 2017

@zapping

This comment has been minimized.

Copy link
Contributor Author

zapping commented Dec 8, 2017

What would go into the parameter val? I tried changing the event to @md-selected="mdSelected(paymentModes)" but still the same result. The pen mentioned above has been modified.

@zapping

This comment has been minimized.

Copy link
Contributor Author

zapping commented Dec 8, 2017

Thank you. Figured it. Its working now.

@VdustR

This comment has been minimized.

Copy link
Member

VdustR commented Dec 8, 2017

No problem.

I already sent a PR for fixing the event emit time.

Your original code will work after it merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.