Okay, this isn't supported yet. It falls under the list of things that there isn't a dynamic setter for. To work around this, we need to destroy and recreate the calendar every time we change the view, which is more feasible than it sounds.
var prevDate = moment("1000-01-01"); //arbitrary "not now" date
var options = { //Store the FC options in a variable
editable: false,
weekMode: 'liquid',
handleWindowResize: true,
weekends: false,
defaultView: 'agendaWeek',
viewRender: function (view, element) {
var newDate = $('#calendar').fullCalendar("getDate");
if (!newDate.isSame(prevDate, 'day')) { //if the date changed
prevDate = moment(newDate);
var events = $('#calendar').fullCalendar("clientEvents"); //Get all current events
$('#calendar').fullCalendar("destroy"); //Remove current calendar
$('#calendar').fullCalendar( //Rebuild the calendar
$.extend({}, options,
getEventLimits(events), //new limits
{defaultDate: newDate}) //preserve the date
);
}
},
events: eventSourceFunction,
};
$('#calendar').fullCalendar(options); //First build
// The following is needed or the first render won't have proper minTime/maxTime
// because events haven't been rendered yet. It just forces a date change.
window.setTimeout(function(){
console.log("timeout date:",prevDate);
var date = moment(prevDate);
$('#calendar').fullCalendar( 'incrementDate', moment.duration("7.00:00:00") );
$('#calendar').fullCalendar("gotoDate",date);
},1);
And to get the limits:
var getEventLimits = function(events){
if(events.length > 0){
var max = events[0].end.format("HH:mm:ss"); // we will only be comparing the timestamps, not the dates
var min = events[0].start.format("HH:mm:ss"); // and they will be compared as strings for simplicity
for(var i = 1; i < events.length; i++){
if(max < events[i].end.format("HH:mm:ss")){
max = events[i].end.format("HH:mm:ss");
}
if(min > events[i].start.format("HH:mm:ss")){
min = events[i].start.format("HH:mm:ss");
}
}
}
return {maxTime:max,minTime:min};
}
A couple of structural changes are also needed as this JSFiddle demonstrates.
Also, I noticed you are using repeating events. Depending on your needs, a solution like my answer here might be simpler and easier to manage.