我正在使用完整的日历jquery插件来创建包含以下代码的时间表
$("#calendar").fullCalendar {
defaultView: 'agendaWeek'
hiddenDays: [0]
axisFormat: 'HH:mm'
minTime: '8:00'
maxTime: '22:00'
selectable: true
agenda: 'h:mm{ - h:mm}'
eventColor: '#00CCFF'
eventBackgroundColor: '#00CCFF'
defaultEventMinutes: 60
editable: true
DurationEditable: true
allDayDefault: false
droppable: true
columnFormat:
week: 'ddd'
eventResize: (event,dayDelta,minuteDelta,revertFunc) ->
alert event
eventDrop: (event,dayDelta,minuteDelta,allDay,revertFunc) ->
$.ajax
url: "/events/#{event.id}"
type: 'PATCH'
data:
'event':
'start' : event.start
'dayDelta' : dayDelta
'minuteDelta' : minuteDelta
success: (data) ->
drop: (date, allDay, jsEvent, ui) ->
copiedEventObject = {}
copiedEventObject.start = date
copiedEventObject.title = $(this).text()
copiedEventObject.data_id = $(this).attr 'data-id'
copiedEventObject.data_type = $(this).attr 'data-type'
copiedEventObject.slotMinutes = Number($(this).attr('data-duration')) * 60
copiedEventObject.allDay = allDay
$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
$(this).hide()
$.post '/events', { 'event' : { 'title' : copiedEventObject.title, 'start' : copiedEventObject.start, 'data_id' : copiedEventObject.data_id, 'data_type' : copiedEventObject.data_type } }, (data) ->
eventSources: [ "/events/?courses=#{courses}" ]
header: {
left: '',
center: '',
right: ''
}
}
timeFormat: 'H(:mm)'
在我的控制器中,我需要在javascript中添加5小时30分钟。
def create
case params[:event][:data_type]
when 'lecture'
parent = Lecture.find(params[:event][:data_id])
when 'tutorial'
parent = Tutorial.find(params[:event][:data_id])
when 'lab'
parent = Lab.find(params[:event][:data_id])
end
params[:event][:start] = DateTime.parse(params[:event][:start]) + 5.hours + 30.minutes
event = parent.create_event(event_params)
if event then parent.update_attribute(:scheduled,true) end
render nothing: true
end
如果我不这样做,在日历上呈现的事件似乎比我放弃它的时间落后5小时30分钟。 为什么问题会出现问题。请帮忙