캘린더에 일정을 동적으로 추가하는 기능이 있습니다.fullCalendar - 색상 옵션이있는 addEventSource
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();
}
});
}
문제는이 방법으로 추가 할 때 이벤트 소스에 색상을 할당하는 방법을 생각할 수 없다는 것입니다.
==== 편집 =====
가 좋아 나는 내가 eventAfterRender를 사용하고 목록에 비교하는 요소 객체의 이벤트의 내부 배경색을 변경하는 hackish 방법을 발견 내가 관련된 색을 가지고있는 사건들. 내가 더 나은 방법을 찾을 때까지 누군가에게 도움이되기를 바란다.
$('#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] })
}
}
}
});
당신은 내가 그 달력 데이터를 가져 오기 된 방식을 변경하고 꺼내 깜빡했다() 콜백에 대한 권리입니다. eventSources 함수에서이를 사용하여 테스트하는 동안 내 차트를 손상시키지 않았습니다. 나는 서브 사이트에서 전달중인 json 객체에 매개 변수를 추가하려고 시도합니다. 감사 – blackops