vue-date-picker
vue-date-picker copied to clipboard
Can't get the picked date value on v-model
Great module but i can't get the value, added a v-model it's not work, how to get the value? Thanks,
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
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 ?
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.
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,
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
Hello @wandersoncmendes, Thanks bro for your response, It's work ! thank you again for your solution. Best,