views:

142

answers:

1

Hello,

I'm using fullcalendar.

And i want to change my calendar, so the default month is June (the initial month for loading), I believe this is what I need: http://arshaw.com/fullcalendar/docs/current_date/month/

The problem is, I'm not very good at .js... and the explanation isn't very clear.

This is what i tried:

<script type='text/javascript'> 

    $(document).ready(function() {

        var date = new Date();
        var d = date.getDate();
        var m = date.getMonth();
        var y = date.getFullYear();

        $('#calendar').fullCalendar('gotoMonth', 7);
        $('#calendar').fullCalendar({
            editable: true,
            events: [
                    {
                    imageAfterTime: $("<img src = 'images/flags/za.png' style='width:19px;height:13px'/>"),
                    imageAfterTitle: $("<img src = 'images/flags/mx.png' style='width:19px;height:13px'/>"),
                    title:' RSA-MEX ',
                    start:   '2010-06-11T14:30:00',
                    allDay: false,
                    },
>>>rest of events...

You can see my calendar at: http://cudamine.com/icame/sitemundial/calendar.html

Can anyone help me out calling this month method?

+1  A: 

"I want to change my calendar, so the default month is June."

The question is a little unclear. Your calendar is starting at June per the month: 5, parameter in the calendar initialization.

BUT the code snippet, above, appears to be trying to go to August (month 7). So what is really wanted?

gotoMonth also appears to be obsolete; it's not in the official documentation (¿anymore?).

You would use the gotoDate function and you would place it after the calendar initialization. Like so:

$(document).ready(function ()
{
    var CurrentDate = new Date();
    var CurrentYear = CurrentDate.getFullYear();

    var MyCalendar  = $('#calendar');
    MyCalendar.fullCalendar(
    {
        defaultView: 'month',
        month: 5,
        editable: true,
        events: [
                {
                    imageAfterTime: $("<img src = 'images/flags/za.png' style='width:19px;height:13px'/>"),
                    imageAfterTitle: $("<img src = 'images/flags/mx.png' style='width:19px;height:13px'/>"),
                    title: ' RSA-MEX ',
                    start: '2010-06-11T14:30:00',
                    allDay: false,
                }
                //... More events ... ...
                ],
        timeFormat: 'H(:mm)',
        eventRender: function (event, eventElement)
        {
            if (event.imageAfterTime)
                eventElement.find('span.fc-event-time').after($(event.imageAfterTime));

            if (event.imageAfterTitle)
                eventElement.find('span.fc-event-title').after($(event.imageAfterTitle));
        }
    });

    //-- Advance to the calendar to August (month 7).
    MyCalendar.fullCalendar( 'gotoDate', CurrentYear, 7);
});
Brock Adams