2013-11-05 71 views
2

我剛剛在FullCalendar上工作。正在關注this thread我可以在從我的頁面上的日期選擇器中選擇特定的日期。FullCalendar FullCalendar - 在周視圖中突出顯示特定日期

我在周視圖中顯示FullCalendar。我的問題是,在周視圖中,我無法在我去過的日期應用fc-state-highlight班。儘管本週有我的要求日期,但它永遠不會突出顯示。

但是,我能夠通過使用

$('.fc-today').removeClass('fc-state-highlight'); 

從當前日期刪除同一類,我需要上面的類添加到我了最新的。

任何幫助將不勝感激。

編輯:我已經發布瞭解決方案我自己。

回答

1

您可以在onload和prev和next按鈕中創建新事件。

功能應該檢查當前週一樣,

$("table.fc-agenda-days").hasClass("td.fc-today") 

or 

if ($("table.fc-agenda-days").find("td.fc-today").length > 0){ 
    $("table.fc-agenda-days td.fc-widget-content").addClass('fc-state-highlight'); 
} 

希望,這會有所幫助。

+0

嗨Sathish所在,我不明白您的解決方案。你確定你瞭解我的要求嗎? – Kumar

+0

Sathish,我編輯了我的帖子,使我的要求更加清晰。無論如何,我試圖包括你的代碼片段,但它沒有奏效。 – Kumar

+0

hi kumar,我已經從你提供的鏈接檢查了fullcalendar周視圖。默認情況下,「fc-state-highlight」類會應用到當前日期[5/11]列,但不是整個星期。我想,你需要整個星期應用突出顯示的風格。你能解釋一下,如果我錯了。 – sathish

5

好吧,夥計們,我爲我的問題制定瞭解決方案。

繼FullCalendar網站上的this documentation後,我使用回調方法dayRender()來解決我的問題。

上述方法有兩個參數datecell。第一個存儲在視圖中的一週中的所有天。因此,考慮到我需要的日期存儲在一個變量reqDate,我做了這樣的事情:

$('#my-div').fullCalendar({ 
    year: reqDate.getFullYear(), 
    month: reqDate.getMonth(), 
    date: reqDate.getDate(), 
    dayRender: function(daysOfWeek, cell) 
    { 
     if(reqDate.getDate()==daysOfWeek.getDate()) 
     { 
      $(cell).addClass('fc-state-highlight'); 
     } 
     else 
     { 
      $(cell).removeClass('fc-state-highlight'); 
     } 
    } 
}); 

就是這樣:)

相關問題