首次加载完整日历时突出显示一些自定义事件

时间:2016-12-05 12:44:53

标签: fullcalendar fullcalendar-scheduler

我在我的项目中使用fullCalendar。我的问题是我想预先设定日历,我正在使用这些设置

initScheduleCalendar = ->
  scheduleCalendar = $('#cloud-recording-calendar').fullCalendar
    axisFormat: 'HH'
    allDaySlot: false
    columnFormat: 'ddd'
    defaultDate: '1970-01-01'
    slotDuration: '00:60:00'
    defaultView: 'agendaWeek'
    dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
    eventColor: '#428bca'
    editable: true

我要强调的日子是

fullWeekSchedule =
  "Monday": ["08:00-17:30"]
  "Tuesday": ["08:00-17:30"]
  "Wednesday": ["08:00-17:30"]
  "Thursday": ["08:00-17:30"]
  "Friday": ["08:00-17:30"]
  "Saturday": []
  "Sunday": []

我希望那些日子在第一页加载时突出显示。我不知道whic选项会用于此吗?任何帮助将不胜感激

1 个答案:

答案 0 :(得分:0)

renderEvents = ->
  schedule = fullWeekSchedule
  days = _.keys(schedule)
  calendarWeek = currentCalendarWeek()

  _.forEach days, (weekDay) ->
    day = schedule[weekDay]
    unless day.length == 0
      _.forEach day, (event) ->
        start = event.split("-")[0]
        end = event.split("-")[1]
        event =
          start: moment("#{calendarWeek[weekDay]} #{start}", "YYYY-MM-DD HH:mm")
          end: moment("#{calendarWeek[weekDay]} #{end}", "YYYY-MM-DD HH:mm")
        scheduleCalendar.fullCalendar('renderEvent', event, true)

currentCalendarWeek = ->
  calendarWeek = {}
  weekStart = scheduleCalendar.fullCalendar('getView').start
  weekEnd = scheduleCalendar.fullCalendar('getView').end
  day = weekStart
  while day.isBefore(weekEnd)
    weekDay = day.format("dddd")
    calendarWeek[weekDay] = day.format('YYYY-MM-DD')
    day.add 1, 'days'
  calendarWeek

我这样做..如果有兴趣知道..