I'm having a problem wit the ui.datepicker. Specifically
setting/getting the default date. I have the following function:
function setDefaultDates() {
var temp = new Date();
var sd = new Date(temp.getFullYear(), temp.getMonth(), temp.getDate()
- 8);
var ed = new Date(temp.getFullYear(), temp.getMonth(), temp.getDate()
- 1);
$("#criteriaStart").datepicker("setDate", sd);
$("#criteriaEnd").datepicker("setDate", ed);
alert(sd + "\n" + $("#criteriaStart").datepicker("getDate"));
$("#criteriaStart").val($.datepicker.formatDate( "d M yy",
$("#criteriaStart").datepicker("getDate") ));
$("#criteriaEnd").val($.datepicker.formatDate( "d M yy",
$("#criteriaEnd").datepicker("getDate") ));
return;
}
The alert() is showing that sd does have a value, but the
datepicker("getDate") bit returns null.
So, the rest of the routine obviously fails because there doesn't appear
to be any value stored in the datepicker.
I've checked the docs and this code looks to be fine. Except for the
formatDate() method. I've tried commenting those lines out without any
difference. (the code was written about a 2 months ago, so may have
been using one version older of the datepicker. The site is now moving
from prototype to production...)
The question is how do I a) set the date for the date picker, then set
the text for the datepicker text box with that date (preferably formated
to the datepickers "dateFormat" option)?
My processing code later looks to the value of the datepicker - not the
text value of the textbox. So if I can't fix this, I need to rip out
the ui.datepicker and use something else. Oh, btw, this is using the
latest UI code (complete set).
Thanks for any tips.
Shawn