Good day
I am using FullCalendar.js for rendreing a Calendar on my form. My requirement is that the user only is allowed to select one slot on the calendar. They're allowed to select multiple slots from different days but, not within the same day.
Also the duration of the slot they can select is maximum of 1 hour and no less than.
I've figured out the latter (allowing a maximum of 1 hour slot that can be selected) however for the life of me, I can't figure out how to "unselect" a previous time selected if a new slot is selected within the same day.
Here's my code:
$('#calendar').fullCalendar({
header:{
left: '',
center: '',
right: ''
},
columnFormat: {
week: 'ddd'
},
selectable:true,
selectHelper: true,
editable: false,
eventStartEditable : false,
allDaySlot: false,
defaultView: 'agendaWeek',
slotDuration:'01:00:00',
allDay: false,
slotEventOverlap: false,
dayClick: function(date,JSevent, view) {
//$(this).fullCalendar('unselect');
console.log("I am hereerer");
$('#calendar').fullCalendar('clientEvents', function(event) {
console.log(date);
console.log(event.start);
console.log(event.end);
if(event.start <= date && event.end >= date) {
return true;
}
return false;
});
},
select:function(start, end)
{
var minutes = end.diff(start,"minutes");
$('#calendar').fullCalendar('unselect');
if(minutes===60)
{
$('#calendar').fullCalendar('renderEvent', {
start: start,
end: end,
allDay: false
},
true
);
}
}
});