on:selected get previous selected value
See original GitHub issueHi, I got some problems when I use the on:selected to passing data to parent component. Here is my code snippet. When I use on:selected to execute the setBeginDate / setEndDate, I will get the previous selected date. Did I do anything wrong?
<template lang="html">
<div>
<datepicker v-model="beginDate" v-on:selected="setBeginDate" format="yyyy-MM-dd" input-class="datepicker-input" wrapper-class="datepicker-wrapper" :clear-button='true'></datepicker>
<datepicker v-model="endDate" v-on:selected="setEndDate" format="yyyy-MM-dd" input-class="datepicker-input" wrapper-class="datepicker-wrapper" :clear-button='true'></datepicker>
</div>
</template>
<script>
import Datepicker from 'vuejs-datepicker';
export default {
data() {
return {
beginDate: new Date(),
endDate: new Date(),
};
},
components: {
datepicker: Datepicker,
},
methods: {
setBeginDate() {
console.log(this.beginDate); // always get the previous selected beginDate date
this.$parent.dateListener(this.beginDate);
},
setEndDate() {
console.log(this.endDate); // always get the previous selected endDate date
this.$parent.dateListener(null, this.endDate);
}
}
}
</script>
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
Getting value of select (dropdown) before change
Lets say currently option My is selected now when I change it to stack in the onchange event (i.e. when I changed it...
Read more >How do I get the text value of a selected option?
Select elements typically have two values that you want to access. First there's the value to be sent to the server, which is...
Read more >Angular Basics: How To Get Value of Selected Dropdown Item
The onSelect method receives the reference variable and takes the value of the dropdown element. The code will look like this: <div class="col ......
Read more >How do I retrieve a selected value of the select control?
Couldn't find the FAQs you're looking for? Please submit your question and answer. Platform.
Read more >Change dropdown value OnSelect - Power Platform Community
OnSelect = UpdateContext({TimeVariable: Dropdown1.Selected.Value})` ... YouTube, and PowerApps Consulting for when you are in a bind to get this fixed ...
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 FreeTop 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
Top GitHub Comments
I had a similar problem. To fix it, I use
watch
property to listen on data change. Here you can do:and it would work for you.