I'm programming a Struts web application using JQuery 1.7 Datepicker on one of my jsps in order to implement a calendar that can highlight reminders for a user.
I have a question:
I'd like to highlight a range of dates in the datepicker. With my code, the Javascript console shows no errors but the range of dates is not highlighted when I log in. this is my function:
$(function(){
$('#datepicker').datepicker({
flat: true,
numberOfMonths: [1,1],
dateFormat: 'dd/mm/yy',
beforeShowDay: highlightDays
});
I have an array of reminders, each reminder has 3 attributes, startDate, endDate and unit (associated unit)
On the beforeShowDay event, the function highlightDays is activated:
function highlightDays(date) {
//For all reminders in the db
for (var i = 0; i < reminders.length; i++) {
//If the current date in between the start and end date of reminder
if( (new Date(reminders[i].start).getTime())
<= date.getTime()
&& (date.getTime())
<= (new Date(reminders[i].end).getTime())) date
{
//Then highlight the current date
return [true, 'ui-state-highlight',reminders[i].unit];
}else{ //Otherwise do not highlight
return [true, ''];
}
}
}
Do you have any idea what I could be doing wrong? What I've implemented so far makes sense to me so I'm not sure what could be going wrong. I would really appreciate some guidance!
Thanks a lot for reading!