2013-03-15 65 views
1

我試圖編輯運行在我的Rails應用程序上的Jquery Fullcalendar。我不知道如何讓它識別來自同一個來源的不同類型的任務,並根據它們的類型對它們進行設計。作爲一個例子,我在實施它時遵循了這個https://github.com/bokmann/fullcalendar-railsFullcalendar在Rails上,針對不同任務的不同顏色

老實說,我甚至不明白風格是如何設置的。即使只是手動設置顏色似乎也沒有改變任何東西,它總是隻有黑色的文本,在當天黃色背景。我已經嘗試了許多解決方案來解決類似的問題,但是他們沒有工作,或者我沒有正確理解它們,並且做錯了什麼。

+0

嘗試爲每個不同類型的任務傳遞不同的CSS類。只是一個想法。 – Zippie 2013-03-15 20:11:22

回答

2

這很容易完成。你只需要在源對象中設置className。 需要相當多的CSS選擇器才能覆蓋默認樣式選項,請參閱您的情況。

CSS:

.fc-content .fc-view .localSource2 div.fc-event-inner { 
    background: red; 
} /* you might want to trim this selector down, but it worked for me */ 

的Javascript:

localSource = { 
    events: [ {title: 'All Day Event', start: new Date(y, m, 1)}, 
      /* More Event Data here */ ], 
    className: 'localSource', // an option! 
    currentTimezone: 'Europe/Bucharest', // an option!   
}; 
USHolidays = { 
    url: 'http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/full',  
    className: 'gcal-event', // an option! 
    currentTimezone: 'America/Chicago', // an option! 
}; 
options = { 
    eventSources: [localSource, USHolidays] 
}; 

fullCalendar(options); // EventSources are set in options 

Event Source Documentation提及其他屬性太(顏色,文本顏色)。

相關問題