只是想知道是否有人有更好的方法来设置一整天的背景在完整的日历js?我的方法的问题是,如果您转到日历中的另一个页面,表格单元格背景仍然改变。我可以重置fullCalendar('prev')事件上的所有背景,我想,但这似乎很混乱。谁知道有什么方法可以渲染实际的事件,使其扩展到整个一天?
var trainingDiary = $("#training_diary").fullCalendar({
dayClick: function(date, allDay, jsEvent, view) {
var title = prompt('Event Title:');
var dayObj = $(this);
//console.log($(this));
if (title) {
$.ajax({
url: "/app_dev.php/addtrainingday",
global: false,
type: "POST",
data: "dayNo=" + date.getDate(), //returns day of month. getDay() returns day of week
async:true,
success: function(msg) {
trainingDiary.fullCalendar('renderEvent',
{
title: title,
start: date,
allDay: allDay,
backgroundColor:'#cccccc'
},
true // make the event "stick" across calendar pages
)
dayObj.css({'background-color':'#339933','background-image':'url()'})
console.log(msg.valueOf());
} //end ajax success
})
} else {
trainingDiary.fullCalendar('unselect');
}
},
//selectable:true,
//selectHelper:true,
theme: true,
header: {left:'title',
center: '',
right: 'today prev next'},
firstDay:1
});
看起来可以通过eventRender()回调来完成。http://arshaw.com/fullcalendar/docs/event_rendering/eventRender/