kenhyuwa/litepie-datepicker

How can i call my function ?

Closed this issue · 3 comments

<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.

Any update on this. Having the same issue

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>