FullCalendar 事件仅在 Safari 上显示
我已经使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我有类似的问题。
对我有帮助的是使用 DateTime 的 .iso8601 函数:
iso8601 格式给出的输出如下:2017-01-25T16:15:49+01:00
I had a similar problem.
What helped me was using the .iso8601 function of DateTime:
iso8601 format gives output like: 2017-01-25T16:15:49+01:00
我有类似的问题。我将日期格式从
“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"
您的字符串格式不正确。
而不是使用
try to use
根据 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
try to use
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/