1
내 루비 앱에서 http://arshaw.com/fullcalendar의 Jquery 전체 캘린더를 사용하고 있습니다. 내 이벤트 테이블에 type_of_event로 저장 한 (휴일, 학교, 직장, 재미)와 같은 4 가지 종류의 이벤트에 서로 다른 색상을 표시하고 싶습니다.Jquery FullCalendar- 루비 앱의 even_type에 따라 이벤트 색상을 변경하십시오.
바로 아래 코드를 사용하여 start_at 및 end_at로 이벤트를 가져옵니다. 이벤트 유형 학교는 그것이 나에게 붉은 색을 보여줍니다 경우
scope :before, lambda {|end_time| {:conditions => ["ends_at < ?", Event.format_date(end_time)] }}
scope :after, lambda {|start_time| {:conditions => ["starts_at > ?", Event.format_date(start_time)] }}
# need to override the json view to return what full_calendar is expecting.
# http://arshaw.com/fullcalendar/docs/event_data/Event_Object/
def as_json(options = {})
{
:id => self.id,
:title => self.title,
:description => self.description || "",
:start => starts_at.rfc822,
:end => ends_at.rfc822,
:allDay => self.all_day,
:recurring => false,
:url => Rails.application.routes.url_helpers.event_path(id),
#:color => "red"
}
end
def self.format_date(date_time)
Time.at(date_time.to_i).to_formatted_s(:db)
end
자신의 EVENT_TYPE에 따라 이벤트 색상을 표시하는 특정 방법이 있나요은