Jquery 完整日历事件不仅在Safari上显示
我使用FullCalendar插件已经有一段时间了,我已经设法让它在FF和Chrome中工作,但我似乎不明白为什么这些事件没有出现在Safari上 我正在使用Rails后端以数组的形式获取事件。这是FireBug显示的事件的JSON对象Jquery 完整日历事件不仅在Safari上显示,jquery,ruby-on-rails,safari,fullcalendar,Jquery,Ruby On Rails,Safari,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 !imp
_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格式,但没有成功。我完全不知道问题出在哪里。非常感谢您的帮助。您的字符串格式不正确 而不是使用
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文档,开始和结束属性需要IETF格式、ISO8601格式或UNIX时间戳的日期对象或字符串。因为strftime(“%Y-%m-%d%H:%m:00”)
不是这些,所以代码无法工作
我也有类似的问题。
帮助我的是使用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我也遇到了类似的问题。我将日期格式从: “2019-05-09 04:00:00” 到
“2019-05-09T04:00:00”这里也有同样的问题。你有没有解决过这个问题?我使用fullCalendar已经有一段时间了,到目前为止,我在Safari中遇到的所有问题都是日期的解析有点不同。例如,(Mac上的Safari 6.0(7536.25)——新日期('01-01-2000')是无效的,而在其他浏览器中它是完全有效的。在这些情况下,您应该用正斜杠替换所有连字符,这样结果类似于新日期('01/01/2000')。“我希望这是有帮助的。”托姆雷兹尼克在我的例子中,是字符串,这个问题让我找对了地方。但这不是破折号与斜线的问题,在我的例子中,破折号的效果非常好。取而代之的是当天的格式,我输出的是一个位数(2012-11-1),缺少的前导0是将其丢弃的。我猜这个错误在接近年底的时候更常见,我敢肯定这个月也有同样的错误,但在10月和11月没有被注意到。老问题,但这个答案似乎不错。从rfc822改为iso8601对我来说很有用。