简体   繁体   English

更改日期时刷新全日历视图

[英]Refreshing fullcalendar view on day change

Assuming a fullcalendar-based application running over midnight, what would be the recommended way to auto-refresh the view in order to have fc-today class properly applied to the new day. 假设一个基于全日历的应用程序在午夜运行,那么为使fc-today类正确地应用于新的一天,自动刷新视图的推荐方法是什么。

Just calling 'today' doesn't have an effect if the current view's date ranges are not changing. 如果当前视图的日期范围未更改,则仅调用“今天”不会产生任何效果。 My current hack is to do something like this after midnight: 我当前的hack是在午夜之后执行以下操作:

calendar.fullCalendar('gotoDate', '2000-01-01');
calendar.fullCalendar('today');

Is there a better/easier way to achieve this? 有没有更好/更容易的方法来实现这一目标?

Sorry that this is 5 years late, but just ran into this same issue and got the solution from a coworker. 抱歉,这已经晚了5年,但是遇到了同样的问题并得到了同事的解决方案。 You can add a key prop to your FullCalendar call and set that to the current date. 您可以将关键道具添加到FullCalendar通话中,并将其设置为当前日期。 This will force it to unmount and remount the component when the date changes. 当日期更改时,这将强制其卸载并重新安装组件。 This is using a TypeScript React implementation of FullCalendar. 这是使用FullCalendar的TypeScript React实现。

getCurrentDay() {
return moment().format('MM-DD-YYYY')
}

<FullCalendar
key={this.getCurrentDay()}
...
/>

I would do this: 我会这样做:

  1. Store a cookie/session variable setting the date/default view you want on next refresh. 存储一个cookie /会话变量,该变量设置您下次刷新时所需的日期/默认视图。
  2. Refresh the page (browser refresh) 刷新页面(浏览器刷新)
  3. Retreive #1 and set the defaults in the fullCalendar(..) call. 返回#1并在fullCalendar(..)调用中设置默认值。

Another option would be to try fullCalendar's reload event call and see if that fully redraws the table? 另一种选择是尝试使用fullCalendar的reload事件调用,看看是否能完全重绘表?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM