FullCalendar:如何使用DayRender功能在每个月的每一天显示图标?

时间:2016-12-01 09:13:39

标签: javascript jquery css fullcalendar

我正在通过FullCalendar制作日历。

我想在当月的每一天显示一个小图标img。关注任何事件。 (假设我根本没有活动)。 我想使用DayRender功能。如果可能的话

这是迄今为止我日历的实现:

        $(document).ready(function() {
        var json_backgrundColor ={"1":"#f1f9ef","2":"#edf5f9","3":"#edf5f9","4":"#f7fafc","5":"#f7fafc","6":"#f7fafc","7":"#f7fafc","8":"#f7fafc","9":"#edf5f9","10":"#edf5f9","11":"#f7fafc","12":"#f7fafc","13":"#f7fafc","14":"#f7fafc","15":"#f7fafc","16":"#edf5f9","17":"#edf5f9","18":"#f7fafc","19":"#f7fafc","20":"#f7fafc","21":"#f7fafc","22":"#f7fafc","23":"#edf5f9","24":"#f1f9ef","25":"#ffdfdf","26":"#ffdfdf","27":"#f1f9ef","28":"#f1f9ef","29":"#f1f9ef","30":"#f1f9ef","31":"#f1f9ef"};

        $('#calendar').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
            },

            defaultView: 'month',
    dayRender: function ( date, cell) {
    var cellDate = date.format('D');
    if(!cell.hasClass('fc-other-month')) {    
        cell.css('background-color', json_backgrundColor[cellDate]);  
    }else {
            cell.css('background-color', '#ffffff');  
            }  
},

        });

    });

https://jsfiddle.net/m53jbwx0/4/

任何人都知道我该怎么做?

非常感谢!

1 个答案:

答案 0 :(得分:4)

你需要这样的东西吗?

dayRender: function ( date, cell) {
cell.prepend('<i class="fa fa-plane" aria-hidden="true"></i>');
}

https://jsfiddle.net/mnjsjs6p

最好的问候 的Krzysztof