I am using Fullcalendar for jQuery and for some reason the calendar is appearing twice on the page. This is not a question about having two instances of fullcalendar on the same page.
Rather, at the bottom of the first calendar, there is a second identical calendar.
I confirmed that there is only one #calendar div in my page, so the error has something to do with my .js that calls fullcalendar.js, I believe.
Any help much appreciated.
JS Code:
jQuery('#calendar').fullCalendar({
year: jQuery.today.getFullYear(),
month: jQuery.today.getMonth(),
date: jQuery.today.getDate(),
theme: true,
contentHeight: 1000,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
defaultView: 'agendaDay',
dayClick: function(date, allDay, jsEvent, view) {
// a lot of custom code
}
});
HTML:
<table><tr><td valign="top" width="700px"><div id="calendar"></div></td></tr></table>
Other call of fullcalendar in javascript (this puts a datepicker in div to left of #calendar div on same page):
jQuery('#datepicker_for_calendar').datepicker({
defaultDate: jQuery.today,
minDate: jQuery.startDate,
maxDate: jQuery.endDate,
inline: true,
showButtonPanel: true,
onSelect: function(dateText, inst) {
var d = new Date(dateText);
jQuery('#calendar').fullCalendar('gotoDate', d);
selectedDate = d;
}
});
Ok, after a long week of bug testing everything, I found this jQuery plugin:
once()
http://plugins.jquery.com/project/once
Once applied to the #calendar div before .fullcalendar, problem solved, only one calendar rendered.
Working code:
…
})