jquery full calendar

13,376

Solution 1

Did you check out the documentation page? The function takes in 2 required parameters and 2 optional ones.

.fullCalendar( 'gotoDate', year [, month, [ date  ]] )

So to set your calendar to April 2010, you would use something like this:

.fullCalendar( 'gotoDate', 2010, 5)

Note that the months are 0-based so April=3.

Solution 2

demo: http://so.lucafilosofi.com/jquery-full-calendar

JS:

        $(function() {
            // build months anchors list
            monthsList('#months-list');

            // inizialize calendar
            $('#calendar').fullCalendar({});

            $(document).on('click', '#months-list a', function() {
                // get month from month anchor hash
                var month = this.hash.substring(1);
                // go to new month
                $('#calendar').fullCalendar('gotoDate', goToMonth(month));
                return false;
            });

            function goToMonth(month) {
                var date = new Date();
                var d = date.getDate();
                var m = month !== undefined ? parseInt(month, 0) : date.getMonth();
                var y = date.getFullYear();
                return new Date(y, m, d);
            }

            function monthsList(element) {
                var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
                for (var m = 0; m < monthNames.length; m++) {
                    $(element).append('<li><a href="#' + m + '">' + monthNames[m] + '</a></li>');
                }
            }

        });

HTML:

    <ul id="months-list"></ul>
    <div id='calendar'></div>

Solution 3

Have you read the API? It seems that if you want to show July 2010 you call:

yourCal.fullCalendar('gotoDate',2010,6);

My answer is simple because I have no idea what you've already tried to do.

Share:
13,376
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    What i have is a tabbed page with 12 tabs (every tab is a month of the year). What i need is when i load jquery calendar, foreach tab, the calendar to switch to the month that is assigned. (e.g when i click and load page for January the calendar shows days for january, and so on).

  • Thea
    Thea over 13 years
    I think that April would be the 3, not 5. 0-base means that the value is decreased by one.
  • Peter Jacoby
    Peter Jacoby over 13 years
    Ah, great point, thanks for the correction. I guess my example was for June instead.