简体   繁体   English

jQuery FullCalendar自定义重复事件

[英]jquery FullCalendar custom recurring events

Im using FullCalendar jquery library for creating events. 我使用FullCalendar jQuery库创建事件。 The requirement here is to create recurring events every x days. 此处的要求是每x天创建重复事件。 For example create an event that is recurring on each second Monday (every 14 days in this case). 例如,创建一个活动,该活动在每个第二个星期一(在这种情况下,每14天一次)重复发生。

Currently the library supports weekly or monthly recurring events. 当前,图书馆支持每周或每月的定期活动。 How can I achieve this? 我该如何实现?

I think @CBroe is correct, you could achive this using your own logic. 我认为@CBroe是正确的,您可以使用自己的逻辑来实现。

To add events to the calendar you must first populate an array of events, this can then be bound to the calendars events property. 要将事件添加到日历,必须首先填充事件数组,然后可以将其绑定到calendars events属性。

For example: 例如:

 var events = getEvents();

$('#myCalendar').fullCalendar({
                    themeSystem: 'bootstrap3',
                    header: {
                        left: 'prev,next today',
                        center: 'title',
                        right: 'month,agendaWeek,agendaDay,listMonth'
                    },
                    weekNumbers: true,
                    weekends: false,
                    navLinks: true, // can click day/week names to navigate views
                    editable: true,
                    eventStartEditable: false,
                    height: 'auto',
                    eventLimit: true, // allow "more" link when too many events
                    events: events,
                    viewRender: function (view, element) {
                        events = getEvents();
                        $('#myCalendar').fullCalendar('removeEvents');
                        $('#myCalendar').fullCalendar('addEventSource', events);
                    },
                });

function getEvents(){
 var events = [];
 var arrayOfDates; //Populate dates at intervals of 14 days

  $.each(arrayOfDates, function () {
                    var date = this;
                        //Create event
                        events.push({
                            title: 'myEvent',
                            start: date,
                            end: date,
                            allDay: true,
                            color: '#228B22',
                            stick: true
                        });

                });
    }

   return events;
}

Well something like that anyway.. this should give you a good starting point 好吧,不管怎样,这应该给你一个很好的起点

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

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