我正在尝试更新Fullcalendar中的事件。我能够使用ajax调用打印事件,但后来我不知道如何使这些事件可编辑。我一直在寻找互联网,这是我尝试过的,但它不起作用。
$(document).ready(function() {
$.get('/controls/calendar', function (data) {
drawControl(data);
});
// page is now ready, initialize the calendar...
function allControls(controls) {
var arrayControls=[];
for (i in controls) {
var level= controls[i].level
var day= controls[i].day
var period=controls[i].period
console.log(controls[i].period)
arrayControls.push({title:level, start:day, description:"period", textColor: 'black'})
}
return arrayControls;
}
function drawControl(controls) {
console.log(controls[0])
$('#calendar').fullCalendar({
aspectRatio: 1,
contentHeight: 500,
scrollTime: '24:00:00',
minTime: '07:00:00',
maxTime: '24:00:00',
defaultView: 'agendaWeek',
header:{left:"prev,next,today",
center:"title",
right:"month, agendaWeek, agendaDay"},
events: allControls(controls),
eventRender: function(event, element) {
var bloodLevel=event.title
if(bloodLevel >= 180) {
element.css('background-color', 'red');
}
else if(bloodLevel < 70) {
element.css('background-color', 'yellow');
}
},
eventClick: function(event, element) {
event.title = "CLICKED!";
$('#calendar').fullCalendar('updateEvent', event);
}
//
// put your options and callbacks here
})
}
});
答案 0 :(得分:0)
fullcalendar中有一个选项。
$('#calendar').fullCalendar({
editable : true,
});
您还可以执行以下特定事件:
var event = {editable:true, start : moment(), end:moment()};