Javascript Arshaw FullCalendar在月视图的每个单元格中添加自定义html
我试图在呈现月份视图时在每个单元格中插入一个自定义html表。为此,我使用ajax调用一个服务。此服务返回一个html表,我将其输入到单元格中 为此,我在fullcalender.js中输入了以下代码Javascript Arshaw FullCalendar在月视图的每个单元格中添加自定义html,javascript,ajax,calendar,asp.net-ajax,Javascript,Ajax,Calendar,Asp.net Ajax,我试图在呈现月份视图时在每个单元格中插入一个自定义html表。为此,我使用ajax调用一个服务。此服务返回一个html表,我将其输入到单元格中 为此,我在fullcalender.js中输入了以下代码 bodyCells.each(function (i, _cell) { cell = $(_cell); date = indexDate(i); if (date.getMonth() == mon
bodyCells.each(function (i, _cell) {
cell = $(_cell);
date = indexDate(i);
if (date.getMonth() == month) {
cell.removeClass('fc-other-month');
} else {
cell.addClass('fc-other-month');
}
if (+date == +today) {
cell.addClass(tm + '-state-highlight fc-today');
} else {
cell.removeClass(tm + '-state-highlight fc-today');
}
cell.find('div.fc-day-number').text(date.getDate());
//Paras Change
$(CallService(date)).appendTo(cell.find('div.fc-day-content').empty());
if (dowDirty) {
setDayID(cell, date);
}
});
在函数bodyCells.each中。其中CallService是我对函数的调用,该函数反过来调用服务
我对该服务的调用位于另一个javascript文件fullcalenderDataHelp.js中,代码如下所示
function CallService(date) {
var table = null;
var newDate = (date.getMonth() + 1) + '/' + (date.getDate()) + '/'+date.getFullYear();
$.ajax({
type: "POST",
url: "http://localhost:57747/ScheduleServer.svc/GetScheduleByDay",
data: '{"day":"' + newDate + '"}',
timeout: 7000,
contentType: "application/json",
success: function (response, textStatus, jqXHR) {
table = $.parseJSON(response.d)
}
})
//alert(table);
return table;
}
当html表被硬编码时,它可以工作,但是当我进行实际的ajax调用并尝试显示html表时,它似乎不起作用。我认为ajax调用需要更多的时间
我将非常感谢您的帮助
谢谢,
第我知道这是一篇老文章。自从我提出这个问题并在我的项目中使用它以来,日历插件本身已经走过了很长的一段路。这与1.5.4版相关。不知道在当前版本中是否仍然可以使用此功能。我在下面提到的plunk中有原始的fullCalendar.js 我最初的问题是关于如何在每月视图的每个单元格中添加自定义HTML 我在发布问题后的几天内找到了答案,但当时我还没有常识将其发布到这里。我一直认为我可以从一些专家那里得到一个更好的方法来回答这个问题 那一天从未到来。我今天试着去网站看看这是否是后来版本中包含的一个功能,但是我找不到任何相关的东西 结果证明答案相当微不足道。在bodyCells.each的函数中,我添加了一行代码,如下所示
$(CallService(date)).appendTo(cell.find('div.fc-day-content').empty());
CallServicedate是一个函数,它返回一些附加到包含作为参数传递的日期的单元格的html
这是一张工作票
但有一件事要记住。在加载月视图中的每个单元格之前调用此函数。这意味着此函数调用将导致延迟
希望这能帮助任何需要自定义HTML的人查看基本的完整日历