如何在Jquery Fullcalendar中为背景事件添加标题?

时间:2016-02-02 12:16:47

标签: fullcalendar

我正在尝试在jquery fullcalendar中的背景事件上放置标题,但它没有显示。

1 个答案:

答案 0 :(得分:0)

我不认为fullcalendar支持本机化,但您可以使用eventRender实现某些功能https://jsfiddle.net/b8n110fm/

$('#calendar').fullCalendar({
  header: {
    left: 'month, agendaWeek, agendaDay',
    center: 'title',
    right: 'prev, next'
  },
  events: [{
    start: '2016-02-01',
    end: '2016-02-10',
    title: 'Testing background event',
    rendering: 'background'
  }, {
    start: '2016-02-01',
    end: '2016-02-10',
    title: 'Testing regular event'
  }],
  eventRender: function(event, element, view) {
    /* Only muck about if it is a background rendered event */
    if (event.rendering == 'background') {
      var bgEventTitle = document.createElement('div');
      bgEventTitle.style.position = 'absolute';
      bgEventTitle.style.bottom = '0';
      /* bgEventTitle.classList.add('fc-event'); */
      bgEventTitle.innerHTML = /*'<span class="fc-title">' + */ event.title /* + '</span>'*/ ;
      /* set container element positioning to relative so the positioning above will work */
      element.css('position', 'relative').html(bgEventTitle);
    }
  }
});