问题
Using latest fullcalendar.io, the number of weeks that are displayed in month view is appropriate for the first month that renders. When using the prev/next buttons, if the next/prev month has less weeks than the current month, it still renders the current month's number of weeks.
Right now it's May 2015. The demo on the site is here: http://fullcalendar.io/js/fullcalendar-2.3.1/demos/gcal.html
May 2015 renders with 6 weeks, because that's how many are needed. When I click next to go to June 2015, 6 weeks are still rendered in month view, even though only 5 weeks are needed.
Question: how can the number of weeks that gets rendered adjust to the actual number of weeks that a given month has? This means that May 2015 would have 6 weeks, but the table would reduce to 5 weeks for June 2015.
This is important when trying to print a monthly calendar. It's May right now, but someone might want to click next and print June, which is coming up. The June calendar should only have 5 weeks, but I can only make it display with 6, since I entered June from May.
Thanks for only tips on this. ryan
回答1:
Your looking for the fixedWeekCount option. From the documentation, you can see that:
If
true
, the calendar will always be 6 weeks tall. Iffalse
, the calendar will have either 4, 5, or 6 weeks, depending on the month.
So, if you want to display the correct number of weeks per selected month, you should set that option to false when fullCalendar is initialized:
$('#calendar').fullCalendar({
fixedWeekCount: false
});
Take a look at this jsfiddle for a working demo.
回答2:
For those poor souls who are still stuck with older version of fullcalendar (v1.6.4) use:
weekMode: "variable"
来源:https://stackoverflow.com/questions/30420463/fullcalendar-month-view-adjust-to-actual-number-of-weeks-in-month