FullCalendar call gotoDate and set firstDay programatically

℡╲_俬逩灬. 提交于 2019-12-13 07:03:43

问题


I have added a custom button to the header of the calendar that has each month of the year in it. The idea is that you can select the month and the calendar will jump to that month.

I currently have firstDay set to 1 to start the calendar on a Monday, this is because in most scenarios I do want Monday to be the first day. When I call gotoDate I would like the calendar to jump to that date with it being the first visible day on the calendar; it should always be the 1st of the selected month.

Currently it goes to the date but the firstDay is Monday of that week.

I have searched to see if I could find anyone else trying to achieve this and came across the this issue but this was for quite an old version of FC, I am using 2.7

Is there a way to pragmatically set the firstDay without forking the calendar and changing the internal code?

Any help would be greatly appreciated.

*I haven't included any code because I don't think it would add any value to the question. I am not calling anything to set the firstDay other than when it is initialised.


回答1:


I have found that as of version 2.9, released on the 11th July 2016 support has been added for getting and setting options dynamically.

I have upgraded from version 2.7 to 2.9 and managed to use the following code to set firstDay after the calendar is initialised.

$('#calendar').fullCalendar('option', 'firstDay', 0);

The documentation for Get/Set Options Dynamically, not all options can be set dynamically.

The GitHub issue that added the functionality.



来源:https://stackoverflow.com/questions/38453735/fullcalendar-call-gotodate-and-set-firstday-programatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!