Reputation: 1036
I am using the fullCalendar plugin and I am trying to figure out how can I determine if the clicked cell is an all-day. I already checked the docs but I can't find it there.
Here's a snippet from my code:
$('.calender').fullCalendar({
allDaySlot: true,
dayClick: function(date, jsEvent, view) {
// click event trigged
// but how can I determine if its an all-day?
}
});
Upvotes: 3
Views: 3511
Reputation: 2316
Use eventClick
.
The first parameter of the eventClick
function callback is the event object.
eventClick: function(calEvent, jsEvent, view) {
// click event trigged
if(calEvent.allDay) {
// all day
}
}
EDIT:
"date holds a Moment for the clicked day. If an all-day area has been clicked, the moment will be ambiguously-timed." - FullCallendar Doc
Try this:
dayClick: function(date, jsEvent, view) {
// click event trigged
if (!date.hasTime()) {
alert("should be all-day");
}
}
Upvotes: 5
Reputation: 281
The below code works, which was found on fullcalendar github page.
dayClick: function(date, jsEvent, view) {
if (!date.hastTime()) {
console.log("It's an all day slot");
} else {
console.log("Not an all day");
}
}
Upvotes: 1