I am trying to get my head around using jQueryUI DatePicker
. One of the main things I must understand is the way a date can be set on page load.
After doing some research, I found 2 different ways to do this:
- using
defaultDate
option - using
setDate
method
The main difference I found out so far is that the defaultDate
option only sets the value in the datePicker calendar itself.
Whereas the setDate
method sets both the date in the input type text
& in the datePicker calendar itself.
One interesting thing is that when using setDate
method & defaultDate
option simultaneously, the date set using setDate
method overrides the value of the date set using the defaultDate
option.
see http://jsfiddle.net/vb7mu3sf/
Another couple of differences I noticed:
- both accepts the date as a Date type as a parameter (which is very neat) but
defaultDate
option accepts additional types (Number & String). setDate
method can of course be called at anytime on the datePicker
Is there anything else I missed about their differences?
Resources: