vue-bulma / datepicker

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

How to clear the input programmatically #62

Open ctessier opened 7 years ago

ctessier commented 7 years ago

Hi,

First, thank you for that awesome component! Works like a charm!

I am looking for a simple way to clear the input programmatically without the use of the data-clear button?

I use the <datepicker> component in the template of another component. I would like to be able to clear the input of the datepicker within a @submit event from the parent form.

Thank you for your help. Regards, Clément

havgry commented 7 years ago

Assuming you're using the v-model binding you can simply set the value of your data property to null. That should clear the input field.

ctessier commented 7 years ago

I indeed use the v-model binding and set the value to empty as you can see here: MenergyForm.vue. Although this doesn't work. I tried setting it to null but same.

Thank you for your help.

havgry commented 7 years ago

Hmm, so while the underlying value is changed the actual input isn't cleared. I've submitted a pull request here: #69

Btw I don't believe your @input="setDate" binding is necessary.

ctessier commented 7 years ago

Thank you. Waiting for the #55 to be merged. I also think your approach is better but we will see :)

cryarchy commented 6 years ago

I also have the same issue. Setting the bound to variable's value to "" or null does not clear the input.