vue-bulma / datepicker

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

How can I use events? #51

Closed andreich1980 closed 7 years ago

andreich1980 commented 7 years ago

I'm reading docs at https://chmln.github.io/flatpickr/events/ but can't figure out how to manage events.

I tried this

<template>
    <datepicker :config="options" v-on:on-open="myMethod"></datepicker>
</template>

and this

<template>
    <datepicker :config="options" v-on:onOpen="myMethod"></datepicker>
</template>

and this

<template>
    <datepicker :config="options" @onOpen="myMethod"></datepicker>
</template>

Nothing happens :(

What am I missing?

andreich1980 commented 7 years ago

Found event @input with Vue browser extension. But when I want to select range it fires twice. Any suggestions?

luventa commented 7 years ago

This component will only emit event input for now. Range selection will definitely fires input twice because the selectedDates changes twice...

Other events that belongs to Flatpickr can be set inside config For example, config like this will works

<datepicker v-model="dateRange" 
  :config="{ mode: 'range', onOpen: this.onRangeOpen }">
</datepicker>

export default {
 methods: {
   onRangeOpen () {
     console.log('test')
   }
 }
}

Here is the events doc for Flatpickr. Event onValueUpdate is not available because this component is using it. Other events can be configured as the example above.