kenhyuwa / litepie-datepicker

Litepie Datepicker is a date range picker component for Vue.js and Tailwind CSS, dependent to day.js.
https://litepie.com
MIT License
373 stars 75 forks source link

How can i call my function ? #66

Closed ramkumar201 closed 2 years ago

ramkumar201 commented 2 years ago

<litepie-datepicker as-single :formatter="formatter" v-model="values[key]" :placeholder="values[key] != '' && !values[na_key] ? values[key] : 'MM-DD-YYYY' " class="zI-1" readonly="readonly" @change="uncheckNa()" :key="!values[na_key] ? 1 : 0"

Here, If I change date in Datepicker, need to call my js func. I use onChange, but it's not working.

FrancoLab commented 2 years ago

Any update on this. Having the same issue

FrancoLab commented 2 years ago

@kenhyuwa ^

FrancoLab commented 2 years ago

Hi, found a way to do this. Might not be the best way but please let me know if you found an alternative to this.

Basically what happens is the callback function runs when the array is greater than 0. Which you can then use to execute your function.

<template>
 <litepie-datepicker
   as-single
   use-range
   :formatter="formatter"
   v-model="dateValue"
 >
 </litepie-datepicker>
</template>
<script setup>
  import { ref, watch } from "vue";
  import LitepieDatepicker from "litepie-datepicker";
  const dateValue = ref([]);
  const formatter = ref({
      date: 'DD MMM YYYY',
      month: 'MMM'
  });

  watch(dateValue, (val) => {
        if (val.length > 0) {
            console.log(dateValue.value);
        }
  });
</script>