jquery full calendar
What i have is a tabbed page wit开发者_StackOverflow社区h 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).
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>
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.
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.
精彩评论