1

I am using fullcalendar, and want to repeat an event once in month (on monday) form August to November. I have been able to repeat the event , but the event repeats four times in a month on each monday of the week -while I need it to repeat once on the first monday after the start date . Below date ranges were passed along with the DOW (days of week ) paramater.

 var repeatingEvents = [{
title:"My repeating event",
id: 1,
start: '10:00', 
end: '14:00', 
dow: [ 1, 4 ], 
ranges: [{ //repeating events are only displayed if they are within at least one of the following ranges.
    start: moment().startOf('week'), //next two weeks
    end: moment().endOf('week').add(7,'d'),
},{
    start: moment('2015-02-01','YYYY-MM-DD'), //all of february
    end: moment('2015-02-01','YYYY-MM-DD').endOf('month'),
},/*...other ranges*/],
},/*...other repeating events*/];

Is there any way I can repeat it once in a month , running it form start date to end date? Any Assistance would be appreciated

Verdu
  • 243
  • 3
  • 13

2 Answers2

2

If you can't generate your events on the server side as @ADyson suggested, you could do it in Javascript. This finds the first Monday of the month, between the specified start and end dates.

var id=0, event, events = [],
    start=moment('2017-08-01'),
    end=moment('2017-10-31');

while (start.isBefore(end)) {
    id++;
    if (start.day() === 'Monday') {
        day = start.format('YYYY-MM-DD');
    } else {
        day = start.add(1, 'weeks').startOf('isoWeek').format('YYYY-MM-DD');
    }
    event = {
        title:"My repeating event",
        id: id,
        start: day + ' 10:00:00', 
        end: day + ' 14:00:00', 
    }
    events.push(event);
    start.add(1, 'month').startOf('month');
}

And then use your constructed array of events in your calendar:

$('#calendar').fullCalendar({
    events: events,
    // ...
Don't Panic
  • 13,965
  • 5
  • 32
  • 51
0

There's no built-in support for this kind of thing unfortunately. If you want to use a "ranges" array like you've shown, this is a completely custom property so you need some custom code to process them. It seems you've used the same structure as in this answer: Recurring Events in FullCalendar . In that case you also need the custom code in the "eventRender" callback which is shown in that answer, in order for the range definitions to be applied.

Another solution is simply to change your server-side code so that it produces a separate event object into the JSON for each required repetition of the event which is required within the date range that fullCalendar requested.

ADyson
  • 57,178
  • 14
  • 51
  • 63