vue-bulma / datepicker

Datepicker Component for Vue Bulma
MIT License
115 stars 56 forks source link

this.$watch('config', this.redraw) doesn't seem to be triggering the redraw method #77

Open soaresdude opened 5 years ago

soaresdude commented 5 years ago
mounted () {
    if (!this.datepicker) {
      this.config.onValueUpdate = this.dateUpdated
      this.datepicker = new Flatpickr(this.$el, this.config)
      this.setDate(this.value)
    }
    this.$watch('config', this.redraw)
    this.$watch('value', this.setDate)
  },

  methods: {
    redraw (newConfig, oldConfig) {
      console.log('oldConfig: ', oldConfig)
      this.datepicker.config = Object.assign(this.datepicker.config, newConfig)
      this.datepicker.redraw()
      this.datepicker.jumpToDate()
    },
    setDate (newDate, oldDate) {
      newDate && this.datepicker.setDate(newDate)
    },
    dateUpdated (selectedDates, dateStr) {
      this.date = dateStr
    }
  },

The redraw method doesn't seem to be triggered with the config watcher. The console.log I've put on it is never called.