Setting datepicker date dynamically #114

Closed
gostbuster opened this Issue Apr 11, 2012 · 1 comment

Comments

Projects
None yet
2 participants

I'm looking for a function that sets the datepicker current date dynamically.

I have 3 inputs which render days, months and years (they are select boxes)

I would like that when I change the day or month or year, this updates the datepicker current date

anyway to do this ? I searched in the source code and didn't find anything.
Thanks

Collaborator

SergioCrisostomo commented Jan 22, 2014

@gostbuster I hope this answers your question.
Sorry the answer took some time to arrive. I post it anyway in case it can be useful for others.
With this answer I will close your issue.

The datepicker has a method to select a date, for that you need a date object.
So the syntax would be:

var myPicker = new Picker.Date(element);
var newDate = Date.parse('date string');  // create a date object from a string
myPicker.select(date);                  // use the .select() method to apply the chosen date

Here is a online demo with a select example as you described.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment