简体   繁体   中英

How to add extra HTML to columnFormat on Fullcalendar

I am using full calendar basicWeek and using columnFormat: 'dd D' which producing the html like:

<th class="fc-day-header ui-widget-header fc-sat fc-future" data-date="2016-12-10">
 <span>Sa 10</span>
</th>

I want to style this data Sa and 10 as different color. So I think, best is to change markup. Seeking suggestion from expert.

Want to make like:

想要这样

Currently looks like:

目前看起来像这样:

As mentioned in the comments, it is not out of the box functionality, but you can try something like this:

var $calendar = $('#calendar').fullCalendar({
  header: {
    left: 'prev,next today',
    center: 'title',
    right: 'month,basicWeek,basicDay'
  },
  defaultView: 'basicWeek',
  dayRender: function(date, cell) {
    var today = new Date();
    var cellIndex = cell[0].cellIndex
    var h = cell.closest('table').find('th').eq(cellIndex);
    if (date.getDate() === today.getDate()) {
      h.html('<span class="c1">' + moment(date).format("ddd") + '</span>&nbsp;<span class="c2">' + moment(date).format("M/D") + '</span>');
    } else {
      h.addClass('c1');
    }
  }
});

http://jsfiddle.net/ogaydvos/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM