FullCalendar事件仅在Safari上显示

Sid*_*Sid 11 safari jquery ruby-on-rails fullcalendar

我一直在使用FullCalendar插件,我已经设法让它在FF和Chrome中运行,但我似乎无法理解为什么这些事件不会出现在Safari上.

我使用Rails后端将事件作为数组获取.这是FireBug显示的事件的JSON对象.

_end: Invalid Date    
_id: "1953"   
_start: Fri Feb 10 2012 00:00:00 GMT+0530 (IST)  
allDay: false  
backgroundColor: "#F60 !important"  
className: Array[0]  
color: "#FFFFFF !important"  
description: ""  
end: Invalid Date  
start: Fri Feb 10 2012 00:00:00 GMT+0530 (IST)   
textColor: "#FFFFFF !important"   
__proto__: Object   
Run Code Online (Sandbox Code Playgroud)

我在safari控制台上没有错误.无效的结束日期显示null在FF和Chrome上.

以下是我填充事件的方式

event[:id]                        = each_event.id    
event[:title]                = each_event.event_title    
event[:allDay]               = each_event.all_day?   
event[:start]                = each_event.start_time.strftime('%Y-%m-%d %H:%M:00')    
event[:end] = each_event.end_date.to_time.strftime('%Y-%m-%d %H:%M:00') if each_event.end_date.present?          
event[:color]                = '#FFFFFF !important'      
event[:backgroundColor]      = (each_event.user ==  current_user) ? '#F60 !important' : '#090 !important'          
event[:backgroundColor]      = '#090 !important' unless each_event.private?       
event[:textColor]            = '#FFFFFF !important'   
Run Code Online (Sandbox Code Playgroud)

我尝试将datetime转换为iso8601格式,但它不起作用.我完全不知道问题是什么.我真的很感激一些帮助.

Kir*_*irk 0

您的字符串格式不正确。

而不是使用

event[:start] = each_event.start_time.strftime('%Y-%m-%d %H:%M:00')
event[:end] = each_event.end_date.to_time.strftime('%Y-%m-%d %H:%M:00') if each_event.end_date.present?
Run Code Online (Sandbox Code Playgroud)

尝试使用

event[:start] = each_event.start_time.to_json
event[:end] = each_event.end_date.to_time.to_json if each_event.end_date.present?
Run Code Online (Sandbox Code Playgroud)

根据 FullCalendar 文档,开始和结束属性需要一个 Date 对象或 IETF 格式、ISO8601 格式或 UNIX 时间戳的字符串。因为strftime('%Y-%m-%d %H:%M:00')这些都不是,所以代码将无法工作。

http://arshaw.com/fullcalendar/docs/event_data/Event_Object/