问题
I think by clicking on the button to display the calendar view eventLimit
with different parameters, because there are a number of events on the page is a user added or modified, but not saved to the server. Users need to switch to a different view of events limit, which is in this jsfiddle
回答1:
To change options when the calendar is already rendered you need to destroy the calendar first, change the option, then build the calendar again. You can do it like this:
var options = $('.calendar').fullCalendar('getView').options;
options.eventLimit = false;
$('.calendar').fullCalendar('destroy');
$('.calendar').fullCalendar(options);
jsfiddle
回答2:
The ability to change options dynamically now exists.
You don't have to destroy the calendar.
The syntax is calendar.setOption('eventLimit',false)
to set the limit and calendar.getOption('eventLimit')
to see what it is.
I wanted to have a button to expand/collapse all events on button click so I made a custom button like this:
calendar = new FullCalendar.Calendar($("#calendar"), {
plugins: [ 'dayGrid', 'interaction', 'timeGrid', 'list' ],
height: 700,
displayEventEnd: true,
customButtons: {
eventLimitButton: {
text: 'Expand/Collapse All',
click: function() {
if(!calendar.getOption('eventLimit'))
calendar.setOption('eventLimit',5); //I set the limit to 5
else
calendar.setOption('eventLimit',false);
}
}
},
header: {
left: 'prev,next today eventLimitButton',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
},
buttonText: {
today: "Today",
dayGridMonth: "Month",
timeGridWeek: "Week",
timeGridDay: "Day",
listWeek: "Weekly List"
},
//...
来源:https://stackoverflow.com/questions/30524881/how-can-change-eventlimit-without-refreshing-the-page-in-order-to-show-the-effec