How can change eventLimit without refreshing the page in order to show the effect of different eventLimit

♀尐吖头ヾ 提交于 2020-01-14 06:36:08

问题


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

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