2014-01-31 76 views

回答

8

可以使用dayRender回調函數:

此回調可以修改日細胞是一個月的部分, basicWeek和basicDay意見。請參閱可用視圖。

date是給定日期的本地Date對象。

檢查顯示是否是一個奇怪的星期六;要做到這一點,你可以得到日期的週數,並檢查它是否奇怪。

代碼:

Date.prototype.getWeekOfMonth = function(exact) { 
    var month = this.getMonth() 
     , year = this.getFullYear() 
     , firstWeekday = new Date(year, month, 1).getDay() 
     , lastDateOfMonth = new Date(year, month + 1, 0).getDate() 
     , offsetDate = this.getDate() + firstWeekday - 1 
     , index = 1 // start index at 0 or 1, your choice 
     , weeksInMonth = index + Math.ceil((lastDateOfMonth + firstWeekday - 7)/7) 
     , week = index + Math.floor(offsetDate/7) 
    ; 
    if (exact || week < 2 + index) return week; 
    return week === weeksInMonth ? index + 5 : week; 
}; 

function isOdd(num) { return num % 2;} 

$('#mycalendar').fullCalendar({ 
    header: { 
     left: 'prev,next today', 
     center: 'title', 
     right: 'month,agendaWeek,agendaDay' 
    }, 
    editable: true, 
    events: [{ 
     title: 'event1', 
     start: '2014-01-07' 
    }, { 
     title: 'event2', 
     start: '2014-01-10', 
     end: '2013-05-15' 
    }, { 
     title: 'event3', 
     start: '2014-01-13 12:30:00', 
     allDay: false // will make the time show 
    }], 
    dayRender: function (date, cell) { 
     if (date.getDay() == 6 && isOdd(date.getWeekOfMonth())) { 
      $(cell).addClass('fc-disabled'); 
     } 
    } 
}); 

演示:http://jsfiddle.net/IrvinDominin/cjTF9/