2015-10-22 91 views

回答

0

我意識到這已經有點老了,但是我可以通過在基於某些事件進行初始化之後設置minTime和maxTime選項來實現此目的。我相信這個功能只能在以後的版本中使用(我使用的是v3.1.0)。

在我的場景中,當用戶點擊當天時,我會根據一週中的哪一天設置開始時間和結束時間。我創建了開閉時間的地圖/字典的每一天:

// Create a map of the ISO day and the start and end times 
// Eg. 1 = Monday, 2 = Tuesday etc 
var openCloseTimes = { 
    // Monday 
    1: { 
     startTime: '09:00:00', 
     endTime: '17:00:00' 
    }, 
    // Tuesday 
    2: { 
     startTime: '09:00:00', 
     endTime: '17:00:00' 
    }, 
    // Wednesday 
    3: { 
     startTime: '09:00:00', 
     endTime: '17:00:00' 
    }, 
    // Thursday 
    4: { 
     startTime: '09:00:00', 
     endTime: '17:00:00' 
    }, 
    // Friday 
    5: { 
     startTime: '09:00:00', 
     endTime: '17:00:00' 
    }, 
    // Saturday 
    6: { 
     startTime: '10:00:00', 
     endTime: '16:00:00' 
    }, 
    // Sunday 
    7: { 
     startTime: '10:00:00', 
     endTime: '16:00:00' 
    } 
} 

然後在我的dayclick功能:

dayClick: function(date, jsEvent, view) { 

    // Get the day of week integer 
    // Eg. 1 = Monday, 2 = Tuesday 
    var dayOfWeek = date.day(); 

    $('.calendar').fullCalendar('option','minTime', openCloseTimes[dayOfWeek].start_time); 
    $('.calendar').fullCalendar('option','maxTime', openCloseTimes[dayOfWeek].end_time); 
} 
相關問題