vue-bulma / datepicker

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

v-model init value #19

Closed dimamarksman closed 7 years ago

dimamarksman commented 7 years ago

Please implement proper working v-model with datepicker to be able to set initial date value.

luventa commented 7 years ago

What's your issue? I think it works properly.

<datepicker v-model="value"></datepicker>

dimamarksman commented 7 years ago

Is there cdn or any public access to the datepicker plugin to show example in a sandbox?

rcubitto commented 7 years ago

I have the same problem...

<datepicker v-model="value"></datepicker> if I set value, it won't be shown in the input.

dimamarksman commented 7 years ago

@luventa what is a reason to assign v-model="value" here? The value is always empty string there that's why the input is always empty in the begining. I dropped this v-model on my side and use defaultDate option (flatpickr) to assign initial value as a workaround. But it is not the way the v-model directive should work. It should be allowed to put an initial value in the datepicker's v-model.

luventa commented 7 years ago

Thought you want a init date for it and here is the example code.

<template>
  <datepicker v-model="value"></datepicker>
</template>

<script>
import Datepicker from 'vue-bulma-datepicker'

export default {
  components: {
    Datepicker
  },

  data () {
    return {
      value: '2016-12-12'
    }
  },
  watch: {
    value (newVal, oldVal) {
      console.log(newVal, oldVal)
    }
  }
}
</script>
dimamarksman commented 7 years ago

Yes, but using wrap: true option.

<template>
  <datepicker v-model="value" :config="{ wrap: true }">
    <a class="button" data-toggle><i class="fa fa-calendar"></i></a>
    <a class="button" data-clear><i class="fa fa-close"></i></a>
  </datepicker>
</template>

<script>
import Datepicker from 'vue-bulma-datepicker'

export default {
  components: {
    Datepicker
  },

  data () {
    return {
      value: '2016-12-12'
    }
  },
  watch: {
    value (newVal, oldVal) {
      console.log(newVal, oldVal)
    }
  }
}
</script>
luventa commented 7 years ago

@dimamarksman I think this is a bug. Will fix

dimamarksman commented 7 years ago

Thank you!

21 февр. 2017 г. 12:22 PM пользователь "Pan Yue" notifications@github.com написал:

@dimamarksman https://github.com/dimamarksman I think this is a bug. Will fix

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vue-bulma/datepicker/issues/19#issuecomment-281302779, or mute the thread https://github.com/notifications/unsubscribe-auth/ADHNACDXbnnpOSbVSKT29JvMp5Cgz9YHks5rerrQgaJpZM4L_PxQ .

luventa commented 7 years ago

fixed. Will publish soon. Feel free to reopen Thanks!

luventa commented 7 years ago

I have to rebase my commits to keep minimum code change. Please check the fix 4dce70f

I will publish this component after other issues are fixed. Please make change locally for time being. Really appreciate.