问题
I have a calendar application using fullcalendar. I actually am using two instances, on top is a month (or optionally week) calendar view, and below is an simple day view (list) of events for the day selected. In month view, I really just want clicking on the day to "select" the whole day. Also, the default longpress seems clunky and slow, so I set the longPressDelay to 1 (ms). I use the callbacks for eventLimitClick and eventClick to select the day as well in case the user clicks there instead of the day itself. This seems to work fine on desktop, but on mobile it selects the day for a fraction of a second then gets un-selected immediately for some reason. Is there a way to stop this? Also I am using a selction constraint so you can only select one day at a time. I tried to use "unselectAuto: false" but that results in weird behavior where previously selected days stay blue even when no longer selected, and it will take two or three clicks to select the next day... not sure why.
Here is my coffeescript initialization code with some extraneous stuff removed.
$('#calendar').fullCalendar
height: 'auto'
nowIndicator: true
defaultView: gon.default_view
header: ''
selectable: true
selectHelper: true
longPressDelay: 1
selectConstraint:
start: '00:00'
end: '24:00'
defaultTimedEventDuration: '00:30:00'
businessHours: {
start: gon.business_hours_start,
end: gon.business_hours_stop,
dow: [0, 1, 2, 3, 4, 5, 6]
}
editable: true
eventLimit: true
eventLimitClick: (cellInfo) ->
$('#calendar-day').fullCalendar('gotoDate', cellInfo.date)
$('#calendar').fullCalendar('select', cellInfo.date)
eventSources: gon.event_sources
eventClick: (e) ->
$('#calendar').fullCalendar('select', e.start)
$('#calendar-day').fullCalendar('gotoDate', e.start)
select: (start, end) ->
$('#calendar-day').fullCalendar('gotoDate', start)
Update:
In some ways I just want the month view to work like a glorified datepicker (a la jquery datepicker), at least on mobile since it's to hard to manipulate events there anyway.
What I have resorted to now is disabling some of the mobile stuff in the library (make getEvIsTouch always return false) then I disabled "editable" option if on mobile (by looking at the user agent).
来源:https://stackoverflow.com/questions/38797059/fix-mobile-day-selection-in-fullcalendar