FullCalendar 事件仅在 Safari 上显示

发布于 2025-01-01 22:44:04 字数 1372 浏览 1 评论 0原文

我已经使用 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'   

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

I've been working with FullCalendar plugin for a bit now and I've managed to get it working in FF and Chrome but I can't seem to understand why the events don't show up on Safari.

I am using a Rails backend to fetch the events as an array. This is the JSON object for the events that FireBug displays.

_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   

I have no errors on the safari console. The invalid end date shows up as null on FF and Chrome.

Here is how I populate the events

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'   

I tried converting the datetime to iso8601 format too and it did not work. I'm completely clueless on what the problem is. I would really appreciate some help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

拧巴小姐 2025-01-08 22:44:04

我有类似的问题。
对我有帮助的是使用 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

I had a similar problem.
What helped me was using the .iso8601 function of DateTime:

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

iso8601 format gives output like: 2017-01-25T16:15:49+01:00

子栖 2025-01-08 22:44:04

我有类似的问题。我将日期格式从

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

更改为

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

I had a similar problem. I switched my date format from:

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

to

"2019-05-09T04:00:00"

殊姿 2025-01-08 22:44:04

您的字符串格式不正确。

而不是使用

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?

try to use

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 文档,开始和结束属性需要 Date 对象或 IETF 格式、ISO8601 格式或 UNIX 时间戳的字符串, 。因为 strftime('%Y-%m-%d %H:%M:00') 不是其中之一,所以代码将无法工作。

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

Your string isn't in the right format.

Instead of using

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?

try to use

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

According to FullCalendar documentation the start and end properties requires a Date object or a string in IETF format, ISO8601 format or a UNIX timestamp. Because strftime('%Y-%m-%d %H:%M:00') is none of those, the code would not work.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文