开发者

Render FullCalendar events on IE 7 & 8

I am using the FullCalendar plugin and everything works well with Firefox and IE 9. However, the events aren't rendering on IE 7 and IE 8.

Here is my javascript code:

$(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;
}

And here is my controller (php code):

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-&开发者_JS百科gt;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);

How can I solve this issue? Also, if someone knows a debug tool for IE, it can help me a lot.


I am having an issue with RenderEvent also. Someone on another thread said they upgraded to 1.4.10 and it fixed it. I have modified the calendar script and can not easily upgrade...

If you are not using 1.4.10 you should try ugrading.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜