Skip to content

Instantly share code, notes, and snippets.

@tareko
Created June 26, 2012 18:29
Show Gist options
  • Select an option

  • Save tareko/2997764 to your computer and use it in GitHub Desktop.

Select an option

Save tareko/2997764 to your computer and use it in GitHub Desktop.
Trying to get the calendar working
function startCalendar() {
$.getJSON(
'<?= $this->Html->url(array('controller' => 'shifts', 'action' => 'listShifts.json')); ?>',
{id: $('<?=$userData?>').val()},
function(json) {
shiftDays = json;
$("#datepicker<?=$calendarId?>").datepicker({
beforeShowDay: shiftsWorking,
dateFormat: 'yy-mm-dd',
onSelect: calendarSelect
});
}
);
}
function shiftsWorking(date) {
for (i = 0; i < shiftDays.shiftList.length; i++) {
console.log(i);
dateDB = new Date(shiftDays.shiftList[i].Shift.date);
if (date.getYear() == dateDB.getYear()
&& date.getMonth() == dateDB.getMonth()
&& date.getDate() == dateDB.getDate() + 1) {
return [true, shiftDays.shiftList[i].Shift.date + '_day'];
}
}
return [false, ''];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment