datepicker icon indicating copy to clipboard operation
datepicker copied to clipboard

How to clear the input programmatically

Open ctessier opened this issue 7 years ago • 5 comments

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

ctessier avatar Jul 23 '17 18:07 ctessier

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.

havgry avatar Aug 05 '17 23:08 havgry

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.

ctessier avatar Aug 09 '17 19:08 ctessier

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.

havgry avatar Aug 09 '17 23:08 havgry

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

ctessier avatar Aug 11 '17 10:08 ctessier

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

cryarchy avatar Sep 09 '18 14:09 cryarchy