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 get the picked date value on v-model #23

Open
dukenst2006 opened this issue Aug 19, 2019 · 6 comments
Open

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

dukenst2006 opened this issue Aug 19, 2019 · 6 comments

Comments

@dukenst2006
Copy link

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

@wandersoncmendes
Copy link

wandersoncmendes commented Aug 20, 2019

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

@dukenst2006
Copy link
Author

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 ?

@wandersoncmendes
Copy link

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.

@dukenst2006
Copy link
Author

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,

@wandersoncmendes
Copy link

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

@dukenst2006
Copy link
Author

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

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

2 participants