I have a jquery datepicker which selects week number and a date range based on what date is picked.
$("input").datepicker({
onSelect: function(dateText, inst) {
$(this).val("Week Number " + $.datepicker.iso8601Week(new Date(dateText)) + " • " + $.datepicker.formatDate('d M', new Date(dateText)) + " - " + $.datepicker.formatDate('d M yy', new Date(new Date(dateText).getTime() + 6*24*60*60*1000)));
}
});
The trouble is, by formatting the date using this method, it prevents the datepicker from defaulting to the selected date when you click the input again. It defaults to the current date.
I have to use this method due to some of the other code I am using (I've avoided showing this because it's long and not relevant to this problem).
Any ideas how I can get it to default to the previously selected date?