FullCalendar dayClick function conflict with select function
I have noticed when I am trying to implement the dayClick: and the select functions there seems to be a collision somewhere.
Here is some narrowed down code.
// WHEN YOU SELECT MULTIPLE DAYS
select: function(start, end, allDay) {
var title = prompt('New Select Date:');
if(title) {
calendar.fullCalendar('renderEvent',
{
title: title,
start: start,
end: end,
allDay: allDay
}, true);
calendar.fullCalendar('unselect');
alert("end of select");
}
},
// ADDING A NEW EVENT
dayClick: function (date) {
alert("Day ("+ date +") was clicked");
},
So the issue comes when I "click开发者_高级运维" on a day, it alerts me which is fine, but then it brings up the prompt for SELECT functionality.
So it runs an ALERT and then a PROMPT window. I am not sure why it's doing this, I haven't been able to narrow down the reasoning, perhaps someone else has had a similar issue?
Please let me know if you have run into a fix or this same issue. Cheers.
What I found out that you don't need to have a SELECT + DAYCLICK for creating a new event. Select works even if it is 1 day, or more. So when I clicked on a day, it prompted with both. Bah, minor issue, but at least I figured it out.
I didn't see this in documentation if it was there. Hopefully it might help someone else.
Cheers.
As Justin said you only need select and not dayClick because both seem to be triggered. However, it seems to me like smartphones for instance require the dayClick because the select isn't triggered on smartphones if you only click on one single date. I haven't tested this so it can be something with my code but it has happened to me twice now and I don't know how to sort it out.
I think i came up with one possible solution and it is as follows:
dayClick: function(date, jsEvent, view) {
if(jsEvent.originalEvent.type=="touchend") {
$('#calendar').fullCalendar('select', date);
}
},
select: function(start, end, jsEvent, view) {
clickOrSelect(start, end, jsEvent, view);
}
function clickOrSelect(start, end, jsEvent, view) {
//put code for both events here
}
精彩评论