vue-date-picker icon indicating copy to clipboard operation
vue-date-picker copied to clipboard

Can't get the picked date value on v-model

Open dukenst2006 opened this issue 5 years ago • 6 comments

Great module but i can't get the value, added a v-model it's not work, how to get the value? Thanks,

dukenst2006 avatar Aug 19 '19 14:08 dukenst2006

See also, you may add :value.sync in the component.

Example: <datepicker :readonly="true" format="YYYY/MM/DD" name="date1" :value.sync="model.entryDate" :input-attr="{placeholder: 'Enter a date'}" ></datepicker>

as described in the Vue description the .sync modifier offers a "bidirectional binding" to a property.

But remember to use it sparingly, as it can cause maintenance difficulties.

For more information, see the official documentation: https://br.vuejs.org/v2/guide/components-custom-events.html#Modificador-sync

wandersoncmendes avatar Aug 20 '19 19:08 wandersoncmendes

Thanks for your answer @wandersoncmendes unfortinately it's not work: <datepicker id="date" :readonly="true" format="YYYY/MM/DD" name="date1" :value.sync="chosedate" :input-attr="{placeholder: 'Enter a date'}" :disabled-date="disabledDate"></datepicker> when i call this.chosedate to get the date value chosen, it's return null, even if i call document.getElementById("date").value) it's return null as well. any idea ?

dukenst2006 avatar Aug 22 '19 13:08 dukenst2006

Hello, from what I realized the component does not support this .sync modifier. I requested the inclusion of this support in the link adding .sync modifier support I am waiting for the return of the project owner.

wandersoncmendes avatar Aug 22 '19 16:08 wandersoncmendes

Thanks for your response, Any other way to get the date picked. I want to get the date and send it to the server. if you find a way to do so, please let me know. Thanks,

dukenst2006 avatar Aug 26 '19 10:08 dukenst2006

While the change is not approved, you can use an advanced technical feature (laughs) to get the value. Add an id attribute inside input-attr and get the value using document.getElementById

Exemplo: <datepicker :readonly="true" :value="valor" format="YYYY-MM-DD" name="date2" :input-attr="{ 'id': 'date' }" ></datepicker>

Get a value: document.getElementById('date').value

wandersoncmendes avatar Aug 26 '19 12:08 wandersoncmendes

Hello @wandersoncmendes, Thanks bro for your response, It's work ! thank you again for your solution. Best,

dukenst2006 avatar Aug 27 '19 00:08 dukenst2006