v-model is not updated in "selected" event handler
See original GitHub issue <datepicker v-model="startDate" :monday-first="true" input-class="input" placeholder="Selecteer..." v-on:selected="doSelection()"></datepicker>
and
methods: {
doSelection: function() {
console.log(this.startDate);
},
},
variable startDate is empty at the first date selection. Second time date is selected (for example different date) the firstly clicked date is shown on the console
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Custom Vue select component not updating selected option ...
Save this question. Show activity on this post. I'm trying to wrap a select in a Vue custom component using the v-model pattern...
Read more >Adding a new todo form: Vue events, methods, and models
As mentioned earlier, v-model syncing works by updating the variable using events. For text inputs, this sync happens using the input event.
Read more >Form Input Bindings - Vue.js
You can use the v-model directive to create two-way data bindings on form input, textarea, and select elements. It automatically picks the correct...
Read more >ASP.NET Core Blazor data binding - Microsoft Learn
The text box is updated in the UI only when the component is rendered, not in response to changing the field's or property's...
Read more >Vue-Multiselect | Vue Select Library
div label.typo__label Single select multiselect( v-model="value", ... react to the search query changes, set a handler function on the @search-change event.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I believe this is because the
selected
event is fired before the VuenextTick
function which updates the v-model. I’m sure if you do this, the second logging will have the value you expect:Even more reason to clarify this in the doc 😃