在完整日历中显示默认标题

时间:2015-03-12 02:44:12

标签: jquery calendar fullcalendar

如果在完整日历中找不到任何活动,则需要在日历中设置默认标题。

$(document).ready(function(){
    var eventMap=[];
    <c:forEach items="${fullCalendarList}" var="inspectorCal">  
            '<fmt:parseDate pattern="dd/MM/yyyy" value="${inspectorCal.end}" var="parsedDate"/>'
            '<c:url value="/secured/inspection/program/showViewInspectorPopUp" var="url"><c:param name="inspectionId">${inspectorCal.id}</c:param><c:param name="inspectionDt">${inspectorCal.start}</c:param></c:url>'
              eventMap.push({
                    "title": '${inspectorCal.title}',
                    "start": new Date('<fmt:formatDate pattern="yyyy" value="${parsedDate}" />', 
                            '<fmt:formatDate pattern="MM" value="${parsedDate}" />'-1, 
                            '<fmt:formatDate pattern="dd" value="${parsedDate}" />'),
                            "textColor": '#000000',
                            "url":'${url}',
                            <c:if test = "${inspectorCal.title == 'Annual Leave'}">
                            "color": '#CCEEFF'
                            </c:if>
                            <c:if test = "${inspectorCal.title == 'Available'}">
                            "color": '#81C6DD'
                            </c:if>
                            </c:if>
                });
            </c:forEach>                
    $('#calendar').fullCalendar({
        year: y,
        month: m-1,
        header: {
            left: 'prev,next today',
            center: 'title',
            right: 'month,agendaWeek,agendaDay'
        },
       titleFormat: {
            month: 'MMMM yyyy'
        },
        editable: true,
        events: eventMap,   
        eventClick: function(event) {
            if (event.url) {
                $(this).showDialog(event.url);
                return false;
            }
        }
    });
});

如何识别事件是空的,以便我们可以将默认标题设置为&#34;可用&#34;。我使用的是spring mvc 3.2和完整日历1.5.3

1 个答案:

答案 0 :(得分:0)

在eventMap中使用其他字段(如emptySlot:true),并在eventRender中检查该字段

eventRender: function (event, element) {
    if(event.emptySlot) {
      //apply your code here
    }
}

有关详细信息,请查看文档click here for docs

相关问题