Ruby on rails Rails jquery fullcalendar可以';t在事件中显示额外字段
我正在rails应用程序中使用jquery fullcalendar。 当前,它在月份显示中显示event.title字段。我希望它也能显示和附加field=workorder.wonum 我在Stackoverflow上找到了这个解决方案Ruby on rails Rails jquery fullcalendar可以';t在事件中显示额外字段,ruby-on-rails,fullcalendar,Ruby On Rails,Fullcalendar,我正在rails应用程序中使用jquery fullcalendar。 当前,它在月份显示中显示event.title字段。我希望它也能显示和附加field=workorder.wonum 我在Stackoverflow上找到了这个解决方案 eventRender: (event, element) -> element.find(".fc-event-title").html(event.title + ": <span>" + event.workorder.wonum
eventRender: (event, element) ->
element.find(".fc-event-title").html(event.title + ": <span>" + event.workorder.wonum + "</span>")
谢谢 我终于明白了 解决方案是将workorder.wonum与标题结合起来:
# 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.workorder.wonum} #{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 => "blue",
:backgroundColor => "blue",
:borderColor => "black",
:textColor => "white"
}
end
在上面的代码中,您有
event.workorder\u num
,而不是\u id
??我的打字错误-谢谢您指出-我更新了问题
# 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.workorder.wonum} #{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 => "blue",
:backgroundColor => "blue",
:borderColor => "black",
:textColor => "white"
}
end