0

I would like to be able to set selected dates of the vue functional-calendar (version 2.8.87) component (https://github.com/Digital-Threads/vue-functional-calendar). I set up the v-model and can detect dates selected by a mouse-click.

But if I set selected-dates from a javascript-function, the calendar does not update and actually mark/select these dates. Below code shows a minimum example. If anyone already accomplished this I would be very thankful for any advise.

<template>
  <div>
    <FunctionalCalendar 
        v-model="calendarData"
        :configs="calendarConfigs"
        ref="Calendar">
    </FunctionalCalendar>

    <b-form @submit="getCal">
        <b-button class="button float-right" type="submit" variant="success">Submit</b-button>
     </b-form>
  </div>
</template>

<script>
import { FunctionalCalendar } from 'vue-functional-calendar';
export default {
  components:{FunctionalCalendar},
  name: 'CustomerArea',
  data() {
    return {
      calendarData:{
        selectedDates : []
      },
      calendarConfigs:{
        isMultipleDatePicker : true
      },
    };
  },
  methods: {
    getCal: function(){
      console.log("getCal called");
      this.calendarData.selectedDates = [{date: '21/7/2020'}];
    }
  }
};
</script>
TobiasWeis
  • 491
  • 6
  • 14

1 Answers1

0

For some reason, one needs to set all other values too (at least to false/invalid), then the selectedDates are marked correctly:

this.calendarData.selectedDates.push({ "date": "21/7/2020", "dateTime": false, "hour": "00", "minute": "00" });
                this.calendarData.selectedDate = false; 
                this.calendarData.selectedDateTime = false;
                this.calendarData.selectedHour = "00";
                this.calendarData.selectedMinute = "00";
                this.calendarData.selectedDatesItem = "";
                this.calendarData.dateRange = { "start": 
                                        { "date": false, "dateTime": false, "hour": "00", "minute": "00" }, 
                                        "end": { "date": false, "dateTime": false, "hour": "00", "minute": "00" } 
                                        };
TobiasWeis
  • 491
  • 6
  • 14