dayClick
Triggered when the user clicks on a date or a time.
function( date, jsEvent, view, [ resourceObj ] ) { }
date
holds a Moment for the clicked day. If an all-day area has been clicked, the moment will be ambiguously-timed. If a slot in the agendaWeek or agendaDay views has been clicked, date
will have the slot’s time.
jsEvent
holds the jQuery event with low-level information such as click coordinates.
view
is set to the current View Object.
Within the callback function, this
is set to the <td>
of the clicked day.
Here is an example that demonstrates all of these variables:
$('#calendar').fullCalendar({
dayClick: function(date, jsEvent, view) {
alert('Clicked on: ' + date.format());
alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
alert('Current view: ' + view.name);
// change the day's background color just for fun
$(this).css('background-color', 'red');
}
});
The resourceObj
parameter
Since the introduction of the Scheduler plugin, this callback reports a Resource Object parameter if the click happened on a resource. More information.
List View
The dayClick trigger is not fired when the user clicks a day heading in list view.
Resource Views
For resource views, this callback will receive an additional Resource Object parameter. Example:
$('#calendar').fullCalendar({
dayClick: function(date, jsEvent, view, resourceObj) {
alert('Date: ' + date.format());
alert('Resource ID: ' + resourceObj.id);
}
});
This is only available with the Scheduler plugin.