FullCalendar js - 在所有日期单元格中添加代码html II

时间:2015-10-09 10:41:53

标签: jquery fullcalendar

昨天,我发布了一个问题,但必要条件已经改变: DOM manipulation for fullCalendar js

现在,图标必须是事件。您无法使用库添加图标" awesome"

从这个例子(代码js)

$(document).ready(function() {

    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();

    var events_array = [];

    var currDate = new Date(new Date().getFullYear(), 0, 1);
    while (currDate.getYear() == 115) {
        currDate.setDate(currDate.getDate() + 1);
        var myDate = new Date(currDate);
        events_array.push({
            title: '2\n3\n1\n1\n1',
            start: myDate           
        })        
    }       

    $("#calendar").fullCalendar({   
        header: {
            left: 'prev',
            center: 'title',
            right: 'next'
        },
        selectable: false,
        monthNames:
            ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
        dayNamesShort:
            ['D', 'L', 'M', 'M', 'J', 'V', 'S'],        
        editable: false,
        eventLimit: true, // allow "more" link when too many events
        eventRender: function(event, element) {
            /*element.find(".fc-time").after($("<span class=\"fc-event-icons\"></span>").html("<ul class=\"fc-icons\">"
            + "<li><img src=\"../img/ico_calen_min_1.png\" /></li>"
            + "<li><img src=\"../img/ico_calen_min_2.png\" /></li>"
            + "<li><img src=\"../img/ico_calen_min_3.png\" /></li>"
            + "<li><img src=\"../img/ico_calen_min_4.png\" /></li>"
            + "<li><img src=\"../img/ico_calen_min_5.png\" /></li>"
            + "</ul>"));

            When activing this code, the event not is visible. i know that i must not to use the  ".fc-time" class. But i have tested with others and nothing (fc-event-container). 

            */
        },
        eventClick: function(event, element) {
            alert("Clic Event");
        },
        events: events_array
    });
});:

从这个例子(代码css)

.fc-event {
    top: 10px;
    margin-left: 20px;
    width: auto !important;
    background: transparent;
    border: 0px solid #3a87ad;
    color: #000;
}



.fc-time{
   display: none;
}

简而言之,我需要在所有日历的所有单元格中进行两个事件,即以下形式:

enter image description here

在eventRender中,我有一个注释代码,关于图标,也许这可能是一个线索。

谢谢,

1 个答案:

答案 0 :(得分:2)

您可以使用eventRender事件将图标添加到dom中,并使用事件文本浮动图标集:

eventRender: function (event, element) {
    element.find('.fc-event-inner').before($("<div class=\"fc-event-icons\"></div>").html("<ul class=\"fc-icons\">" + "<li><img src=\"--\" /></li>" + "<li><img src=\--\" /></li>" + "</ul>"));
},

和一点造型:

.fc-event {
    top: 10px;
    background: transparent;
    border: 0px solid #3a87ad;
    color: #000;
}
.fc-event-icons {
    float: left;
    margin-right: 5px;
}
.fc-event-inner {
    width: 20px;
}

结果: enter image description here

演示:http://jsfiddle.net/dcx5unzd/4/