Javascript jQuery fullCalendar-扩展buildCellHTML函数?

Javascript jQuery fullCalendar-扩展buildCellHTML函数?,javascript,jquery,fullcalendar,odoo-8,Javascript,Jquery,Fullcalendar,Odoo 8,我想扩展fullCalendar,使其在各自的日期单元格中显示特殊的日期名称。例如,如果用户将定义特殊日期(在后端)2017-12-25并将其称为Christmas,通过进入日历,他将在该单元格上看到Christmas单词(比如在左上角) 因此,查看fullCalendar源代码,我可以看到它使用以下函数构建这些单元格: function buildCellHTML(date) { var contentClass = tm + "-widget-content";

我想扩展
fullCalendar
,使其在各自的日期单元格中显示特殊的日期名称。例如,如果用户将定义特殊日期(在后端)
2017-12-25
并将其称为
Christmas
,通过进入日历,他将在该单元格上看到
Christmas
单词(比如在左上角)

因此,查看fullCalendar源代码,我可以看到它使用以下函数构建这些单元格:

function buildCellHTML(date) {
        var contentClass = tm + "-widget-content";
        var month = t.start.getMonth();
        var today = clearTime(new Date());
        var html = '';
        var classNames = [
            'fc-day',
            'fc-' + dayIDs[date.getDay()],
            contentClass
        ];

        if (date.getMonth() != month) {
            classNames.push('fc-other-month');
        }
        if (+date == +today) {
            classNames.push(
                'fc-today',
                tm + '-state-highlight'
            );
        }
        else if (date < today) {
            classNames.push('fc-past');
        }
        else {
            classNames.push('fc-future');
        }

        html +=
            "<td" +
            " class='" + classNames.join(' ') + "'" +
            " data-date='" + formatDate(date, 'yyyy-MM-dd') + "'" +
            ">" +
            "<div>";

        if (showNumbers) {
            html += "<div class='fc-day-number'>" + date.getDate() + "</div>";
        }

        html +=
            "<div class='fc-day-content'>" +
            "<div style='position:relative'>&nbsp;</div>" +
            "</div>" +
            "</div>" +
            "</td>";

        return html;
    }
函数buildCellHTML(日期){
var contentClass=tm+“-widget content”;
var month=t.start.getMonth();
var today=clearTime(新日期());
var html='';
变量类名称=[
‘足球俱乐部日’,
“fc-”+dayIDs[date.getDay()],
内容类
];
if(date.getMonth()!=month){
push('fc-other-month');
}
如果(+日期==+今天){
classNames.push(
‘今日足球俱乐部’,
tm+“-状态突出显示”
);
}
否则,如果(日期<今天){
push('fc-pass');
}
否则{
push('fc-future');
}
html+=
"" +
"";
如果(显示编号){
html++=“date.getDate()+”;
}
html+=
"" +
" " +
"" +
"" +
"";
返回html;
}
现在,如果我要通过添加以下行直接修改fullCalendar库:

html+=“占位符”

在此之前:

if(显示编号){
html++=“date.getDate()+”;
}

它确实添加了我基本需要的内容,但当然我不想直接修改库,我想扩展它。查看文档,我似乎找不到如何扩展day cell内容

这个函数是另一个函数的内部函数,所以我不能访问它(或者我可以?)。但是,也许有人对fullCalendar更有经验,可以告诉我们如何做这个扩展

注:我指的是全天单元格,而不是事件(附加了特定事件)。我的意思是,它应该检查那个天是否是特殊的一天,不管那个天是否有事件发生(尽管后端的实际特殊日期实现在这里并不相关)


我使用的p.S.S.fullCalendar版本是
1.6.4

我可以修改单元格内容,如Adyson和m.D建议的那样。所以我找到的确切片段是这样的(占位符只是为了显示它正在被更改):

instance.web\u calendar.CalendarView.include({
get_fc_init_选项:函数(){
fc_options=这个。_super()
返回$.extend({},fc_选项{
dayRender:函数(日期、单元格){
cell.children('div'))
.prepend('占位符')
}
});
},
})
请注意,我使用的是
this.\u super()
。这是为了让Odoo像其他OOP语言一样模仿继承而实现的


注意:这仅适用于<代码>月份日历视图。切换到
week
day
视图,将不会产生任何效果。

您可能会考虑过这一点。在日历()上实现“dayRender”回调不允许您执行所需的操作吗?如果在JS数组中预先加载了一组“特殊”日期,则可以对照列表检查每个渲染的日期,以查看是否需要显示额外的信息)。另外,考虑更新你的全日制版本- 1。X已经失去支持一段时间了。3.3.1是最新版本!我使用eventRender回调,通过您可以在eventRender中访问的元素将html附加到事件中。有一个dayRender回调。也许你可以用这个回调做一些类似的事情?@ADyson可能会尝试类似的事情,尽管我不知道我应该从哪里抓住那些被渲染的日子?我所看到的是,定义了一些事件渲染函数,但我需要捕捉天数,而不是事件。也许你可以举一些例子,让它更清楚?对于版本,不幸的是,我绑定到该版本,因为它是另一个使用fullCalendar的系统的一部分(如果我切换,它可能会破坏与其他系统部件的兼容性)。问题是calendar对象已经初始化,所以执行类似于
$(“#calendar”).fullCalendar({dayRender:function(date,cell){cell.css(“background color”,“red”);}}}实际上会创建新的日历。显然,您需要在现有选项中插入一个“daydrender”方法-可能在页面的某个地方已经调用了
$(“#calendar”).fullCalendar({…
?。您只需将dayRender方法作为新选项放入现有代码中。您不想重新初始化日历是正确的。
instance.web_calendar.CalendarView.include({
    get_fc_init_options: function(){
        fc_options = this._super()
        return $.extend({}, fc_options, {
            dayRender: function(date, cell){
                cell.children('div')
                    .prepend('<div style="float:left; padding: 0 2px">placeholder</div>')
            }
        });
    },
 })