我正在使用FullCalendar插件,一切都适用于Firefox和IE 9.但是,事件不会在IE 7和IE 8上呈现。
这是我的javascript代码:
$(document).ready(function() {
initCalendar();
var currentMonth;
var currentYear;
var todayMonth;
var todayYear;
function initCalendar() {
var currentDate = new Date();
currentMonth = (currentDate.getMonth() + 1 < 10 ? '0'+(currentDate.getMonth() + 1) : currentDate.getMonth() + 1);
currentYear = currentDate.getYear() + 1900;
todayMonth = currentMonth;
todayYear = currentYear;
var language = $('#param_language').val();
var listMonth = ['JANUARY','FEBRUARY','MARCH','APRIL','MAY','JUNE','JULY','AUGUST','SEPTEMBER','OCTOBER','NOVEMBER','DECEMBER'];
var listDayShort = ['SUNDAY','MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY'];
if (language == 'fr_FR') {
listMonth = ['JANVIER','FEVRIER','MARS','AVRIL','MAI','JUIN','JUILLET','AOUT','SEPTEMBRE','OCTOBRE','NOVEMBRE','DECEMBRE'];
listDayShort = ['DIMANCHE','LUNDI','MARDI','MERCREDI','JEUDI','VENDREDI','SAMEDI'];
}
$('#calendar').fullCalendar({
editable: true,
disableDragging : true,
disableResizing : true,
eventClick: function (event) {
window.location = '/calendar/caldetail/id/'+event.id+'/num/'+event.timestamp;
},
monthNames:listMonth,
dayNamesShort:listDayShort
});
$('.fc-button-prev').click(function () {
currentMonth --;
if (currentMonth == 0) {
currentMonth = 12;
currentYear --;
}
if (currentMonth-1 == 0) {
getAllMonthEvent(12, parseInt(currentYear)-1);
} else {
getAllMonthEvent(parseInt(currentMonth)-1, currentYear);
}
});
$('.fc-button-next').click(function () {
currentMonth ++;
if (currentMonth == 13) {
currentMonth = 1;
currentYear++;
}
if (parseInt(currentMonth)+1 == 13) {
getAllMonthEvent(1, parseInt(currentYear)+1);
}
else {
getAllMonthEvent(parseInt(currentMonth)+1, currentYear);
}
});
$('.fc-button-today').click(function () {
currentMonth = todayMonth;
currentYear = todayYear;
getAllMonthEvent(currentMonth, currentYear);
});
if (parseInt(currentMonth)-1 == 0) {
getAllMonthEvent(12, parseInt(currentYear)-1);
} else {
getAllMonthEvent(parseInt(currentMonth)-1,currentYear);
}
getAllMonthEvent(currentMonth, currentYear);
if (parseInt(currentMonth)+1 == 13) {
getAllMonthEvent(1, parseInt(currentYear)+1);
} else {
getAllMonthEvent(parseInt(currentMonth)+1, currentYear);
}
}
});
function getAllMonthEvent(month, year) {
if (!isAlreadyGenerated(month, year)) {
messbox.open(MSG_LOADING);
var params = {
month: month,
year:year
};
$.post("/calendar/getallevents",
params,
function(data){
messbox.close();
addGeneratedDate(month, year);
$.each(data, function(i, calevent){
$('#calendar').fullCalendar('renderEvent', calevent, true);
});
},
'json'
);
}
}
var listGeneratedPage = new Array();
function addGeneratedDate(month,year) {
var elt = new Array(month, year);
listGeneratedPage.push(elt);
}
function isAlreadyGenerated(month, year) {
for (i=0; i<listGeneratedPage.length; i++) {
if (listGeneratedPage[i][0] == month && listGeneratedPage[i][1] == year) {
return true;
}
}
return false;
}
这是我的控制器(php代码):
foreach($listCalendar as $calendar) {
if($calendar->getTimezone()){
$date = new DateTime($calendar->getDate(), new DateTimeZone('GMT'));
$date->setTimezone(new DateTimeZone($user->getTimezone()));
$datetime = $date->format('Y-m-d H:i:s');
} else{
$datetime = $calendar->getDate();
$datetime = @date('Y-m-d H:i:s',strtotime($datetime));
}
$timestamp = strtotime($datetime);
$tmp = explode(' ',$datetime);
$hour = explode(':',$tmp[1]);
$className = 'event-type-other';
if ($calendar->getType() == 'R') {
$className = 'event-type-running';
}
if ($calendar->getFrequency() == 'N' && $calendar->getPeriod()) {
$elt = array(
'id' => $calendar->getId(),
'timestamp' => $timestamp,
'title' => substr($calendar->getName(),0,12).' ('.$hour[0].':'.$hour[1].')',
'start' => $calendar->getDate(),
'end' => date('Y-m-d H:i:s',strtotime("+".$calendar->getPeriod()." minutes", strtotime($calendar->getDate()))),
'className' => $className
);
} else {
$elt = array(
'id' => $calendar->getId(),
'timestamp' => $timestamp,
'title' => substr($calendar->getName(),0,12).' ('.$hour[0].':'.$hour[1].')',
'start' => $calendar->getDate(),
'className' => $className
);
}
$listEvent [] = $elt;
}
echo json_encode($listEvent);
我该如何解决这个问题?此外,如果有人知道IE的调试工具,它可以帮助我很多。
答案 0 :(得分:0)
我也遇到了RenderEvent的问题。另一个线程上有人说他们升级到1.4.10并修复了它。我修改了日历脚本,无法轻松升级......
如果您不使用1.4.10,则应尝试升级。