Listener for "date change" in FullCalendar?
In V5 you have to use datesSet instead of datesRender.
Bill,
I know this question is pretty much ancient, but I needed a solution and figured I'd post it here for others. I solved the problem myself by attaching the viewDisplay
event to my calendar (this event was removed in v2 of FullCalendar, viewRender
may be used instead).
$("#calendar").fullCalendar({
viewDisplay: function (element) {
}
});
Once you have access to the element parameter, you can get the date by using element.start
or element.visStart
. If you're in the month view, start will provide you with the first day of the month that you're viewing, visStart will give you the first visible day of the month
For FullCalendar v4 (the latest version at the time of writing ) the right callbacks are:
viewSkeletonRender (docs)
function( info )
This callback will get triggered when the initial view renders or when the user changes the view, but before the datesRender callback fires, which is a callback for when all date/time cells have been rendered.
datesRender (docs)
function( info )
This triggers after viewSkeletonRender callback but before the eventRender callbacks.
This is how I did it:
$("#calendar").fullCalendar({
viewRender: function(view, element){
var currentdate = view.intervalStart;
$('#datepicker').datepicker().datepicker('setDate', new Date(currentdate));
}
});
In month view, intervalStart
will return the first day of the month being displayed on the FullCalendar, rather than the first visible day, which is usually a day near the end of the previous month.