I would like to find out how can I limit the fullcalendar to show a three months period and deselectable for the rest of the months like within a datepicker?
E.g. T
I was facing a similar situation: I have a program of events and wanted to limit the Fullcalendar to the date range for the events (e.g., 12 weeks). So, if today is in week 6, then the calendar only displays the dates from week 1 to 12 when the user clicks next or previous. I looked at modifying fullcalendar.js but do not have time to detour from my project timeline to do so. So as a workaround here is what I did:
In your custom jQuery file .js, add to the fullCalendar method for dayClick which takes date as variable:
if (+date < +jQuery.startDate || +date > jQuery.endDate) {
var $date_out_of_range_dialog = jQuery('') .html('
Sorry, the date you selected is outside the date range for the current program.
Start Date: '+ (jQuery.startDate.getMonth() + 1) + '/' +jQuery.startDate.getDate() + '/' +jQuery.startDate.getFullYear() +'
End Date: ' + (jQuery.endDate.getMonth() + 1) + '/' +jQuery.endDate.getDate() + '/' +jQuery.endDate.getFullYear() + '
') .dialog({ autoOpen: false, modal: true, title: 'Date Out of Range', width: 600, buttons: { "Ok": function() { jQuery(this).dialog("close"); } } })$date_out_of_range_dialog.dialog('open');
} else {
//do something else like view/add/delete event for that day in range.
}
The .dialog method to open the dialog window is from mootools, but something similar can be used in jQuery. I prepended jQuery. to startDate and endDate so that the vars were available throught my .js file.
Here is the code for the datepicker to pick date and select on fullCalendar:
jQuery('#datepicker_for_calendar').datepicker({ defaultDate: jQuery.startDate, minDate: jQuery.startDate, maxDate: jQuery.endDate, inline: true, showButtonPanel: true, onSelect: function(dateText, inst) { var d = new Date(dateText); jQuery('#calendar').fullCalendar('gotoDate', d); selectedDate = d; } });