gpt4 book ai didi

javascript - fullCalendar - 带有颜色选项的 addEventSource

转载 作者:行者123 更新时间:2023-11-30 13:28:36 25 4
gpt4 key购买 nike

我有一个动态添加事件到日历的功能。

function AddEventSourceDetailed(act_id) {
$('#calendar').fullCalendar('addEventSource', function (start, end, callback) {
var startTime = Math.round($('#calendar').fullCalendar('getView').start.getTime() / 1000);
var endTime = Math.round($('#calendar').fullCalendar('getView').end.getTime() / 1000);
time = endTime - startTime;
//alert(time);
if (time <= 604800) {
$.ajax({
type: 'POST',
url: '/Employee/GetScheduleDetailedArray/',
async: false,
dataType: "json",
data: {
// our hypothetical feed requires UNIX timestamps
start: Math.round(start.getTime() / 1000),
end: Math.round(end.getTime() / 1000),
id: '@Model.selectedUserId',
act: act_id
},
success: function (doc) {
callback(doc);
},
error: function (xhr, status, error) {
document.appendChild(xhr.responseText);
}
}); //end ajax
} else {
callback();
}

});
}

问题是我不知道如何在以这种方式添加时为事件源分配颜色。

====编辑=====

好吧,我找到了一种更改事件内部背景颜色的 hackish 方法,我使用 eventAfterRender 及其元素对象将其与我具有关联颜色的事件列表进行比较。我希望在我找到更好的方法之前,这会对某人有所帮助

 $('#calendar').fullCalendar({
height: 600,
width: 700,
header: {
right: 'prev,next today',
center: 'title',
left: 'month,agendaWeek,agendaDay'
},
eventAfterRender: function (event, element, view) {
for (x = 0; x < activityColors[0].length; x++) {
if (event.id == activityColors[0][x]) {
element.children().css({ "background-color": "#" + activityColors[1][x] })
}
}

}
});

最佳答案

您可以使用:

$('#calendar').fullCalendar( 'addEventSource', {
url: "/url/goes/here",
color: '#05ABBD'
});

关于javascript - fullCalendar - 带有颜色选项的 addEventSource,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7598644/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com