我已经实现了 fullcalendar v2 资源日历。我无法解决的是基于天设置动态minTime和maxTime 。每天都有不同的工作时间。
周一 10:00 至 14:00
周二 16:00 至 24:00 ...
我以这种方式初始化了我的日历:
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,resourceDay'
},
defaultView: 'resourceDay',
titleFormat: {'day':'dddd, MMMM D'},
minTime: "08:00",
maxTime: "20:00",
scrollTime: moment().format('H:m'),
eventLimit: true, // allow "more" link when too many events
resources:[
resource1,resource2
],
slotDuration: '00:15:00',
allDaySlot: false,
lazyFetching: false,
droppable: true,
defaultTimedEventDuration: '00:30:00',
selectable: true,
selectHelper: true,
unselectAuto: 'true',
timeFormat: {'agenda':'hh:mm A','':'hh:mm A'},
// Calender Method-1: AJAX events will loaded from this code
events:function(start, end, timezone,callback) {
$.ajax({
url: "http://www.domainn.com/dashboard/index",
dataType: 'json',
type:'POST',
// async: false, //blocks window close
data: {
start: start.unix(),
end: end.unix(),
viewtype: $('#calendar').fullCalendar('getView').name,
},
success:function(response){
var calendarOptions = $('#calendar').fullCalendar('getView').calendar.options;
// console.log(calendarOptions);
calendarOptions.minTime = response.timings.start;
calendarOptions.maxTime = response.timings.end;
$('#calendar').fullCalendar('destroy');
$("#calendar").fullCalendar(
$.extend(calendarOptions, {
events:response.resources
})
);
}
});
},
eventRender: function (event, element) {
// code here
},
// other events follows.....
});
从这个 ajax 调用并根据我获得该特定日期的动态工作时间并尝试将其设置为
response.timings.start
response.timings.end
但是使用这些选项,然后在任何其他日子更改/前往,不会获取事件!基本上,它会在一个循环中无限地调用相同的函数。
尝试了很多选择,但没有运气。任何帮助/指南将不胜感激。谢谢。