Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't delete a date once selected #76

Open
sofuxro opened this issue Jan 30, 2018 · 2 comments
Open

Can't delete a date once selected #76

sofuxro opened this issue Jan 30, 2018 · 2 comments

Comments

@sofuxro
Copy link

sofuxro commented Jan 30, 2018

I've tried this:

<datepicker :model="startAt" :config="{ wrap: true }">
    <a class="button" data-clear><i class="fa fa-close"></i></a>
</datepicker>

(it does remove it from the input but the date persists in the model
=> the user doesn't see a date anymore, but the code still has it)

I saw that flickr (the one implemented here) can delete dates with Backspace. On this datepicker I can't do that either.

Am I missing something ? how can I set my startAt to null or empty string

@dgriego
Copy link

dgriego commented Feb 28, 2018

I am also having this same issue,

I tried adding a click event in addition to the data-clear like so (primitive example):

<a class="button" data-clear @click="clearDate"><i class="fa fa-close"></i></a>

...
clearDate() {
  this.date = ''
}

this actually updated the data to the value I wanted, but visually it would clear and then the date would somehow reappear even though the data properties value was now an empty string. If you try this method you will have to click twice to remove it from the UI as well. Nevertheless, I would like to implement this in a cleaner way and using the default API that flatpickr offers.

@jaybeecave
Copy link

Agreed this is annoying but you can do something like

    clearDatePicker () {
      this.$emit('input', null)
      this.$nextTick(() => {
        this.$refs['field'].datepicker.clear()
      })
    },

I have the datepicker wrapped in my own control

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants