FullCalendar事件仅在Safari上显示

问题描述 投票:11回答:3

我一直在使用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   

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

以下是我填充事件的方式

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'   

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

jquery ruby-on-rails safari fullcalendar
3个回答
1
投票

我遇到了类似的问题。帮助我的是使用DateTime的.iso8601函数:

event[:start] = each_event.start_time.iso8601
event[:end] = each_event.end_date.to_time.iso8601 if each_event.end_date.present?

iso8601格式给出如下输出:2017-01-25T16:15:49 + 01:00


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?

试着用

event[:start] = each_event.start_time.to_json
event[:end] = each_event.end_date.to_time.to_json if each_event.end_date.present?

根据FullCalendar文档,start和end属性需要Date对象或IETF格式的字符串,ISO8601格式或UNIX时间戳。因为strftime('%Y-%m-%d %H:%M:00')不是那些,所以代码不起作用。

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


0
投票

我遇到了类似的问题。我切换了日期格式:

"2019-05-09 04:00:00"

“2019-05-09T04:00:00”

© www.soinside.com 2019 - 2024. All rights reserved.