_docs-v6/date-clicking-selecting/dateClick.md
Triggered when the user clicks on a date or a time.
<div class='spec' markdown='1'> function( dateClickInfo ) { } </div>In order for this callback to fire, you must load the interaction plugin. If you are using an ES6 build system:
import { Calendar } from '@fullcalendar/core';
import interactionPlugin from '@fullcalendar/interaction';
...
let calendar = new Calendar(calendarEl, {
plugins: [ interactionPlugin ],
...
dateClick: function(info) {
alert('Clicked on: ' + info.dateStr);
alert('Coordinates: ' + info.jsEvent.pageX + ',' + info.jsEvent.pageY);
alert('Current view: ' + info.view.type);
// change the day's background color just for fun
info.dayEl.style.backgroundColor = 'red';
}
});
...
Alternatively, you can use a global bundle:
<script src='fullcalendar/dist/index.global.js'></script>
<script>
...
var calendar = new FullCalendar.Calendar(calendarEl, {
// no plugin configuration required!
});
...
</script>
dateClickInfo is a plain object with the following properties:
The dateClick trigger is not fired when the user clicks a day heading in list view.
For resource views, this callback will receive an additional Resource Object parameter. Example:
var calendar = new FullCalendar.Calendar(calendarEl, {
dateClick: function(info) {
alert('Date: ' + info.dateStr);
alert('Resource ID: ' + info.resource.id);
}
});
Resources are a premium feature.