Recurring Events in FullCalendar

后端 未结 8 1044
独厮守ぢ
独厮守ぢ 2020-11-22 09:49

I am using jQuery FullCalendar as my calendar used in my website for availability agenda.

Is there any functions/methods/options in fullcalendar that handles my recu

8条回答
  •  无人及你
    2020-11-22 10:39

    This seemed to work quite nicely within the eventRender: function(event, element){}

                EXAMPLE JSON:
                var json = [{title: "All Day Event",
                  start: "2015-12-22T00:00",
                  end: "2015-12-22T23:55",
                  dow: [2,4],
                  recurstart: moment("2015-12-22").startOf("week"),
                  recurend: moment("2015-12-22").endOf("week").add(1,'w')},{
                  title: "Long Event",
                  start: "2015-12-21T00:00",
                  end: "2015-12-24T23:55",
                  recurstart: moment("2015-12-21").startOf("month"),
                  recurend: moment("2015-12-24").endOf("month"),
                }];
    
                eventRender: function(event, element){
                var theDate = moment(event.start).format("YYYY-MM-DD");
                var startDate = event.recurstart;
                var endDate = event.recurend;
    
                if (startDate < theDate && theDate < endDate) {
                    console.log(theDate);
                    }
                else {
                    return event.length>0;
                }
                }, /* End eventRender */
    

    1) Set a Start/End date & time in the JSON.

    2) Create two custom recur Start and recur Ends in the JSON.

    3) Use moment.js to create the recur durations: http://momentjs.com/docs/#/durations/.

    4) Recur Start uses the (start:) date to pinpoint the start of the week.

    5) Recur End uses (end:) date to pinpoint the end of the week + adding 1 week.

    6) Adding 1, 2, 3 weeks can create the recur limit.

    7) Adding another part of the JSON called (recurlimit:"") could manage the recur limit.

    8) Using variables within the eventRender - set the date my example uses (theDate) which is moment(event.start). It's important to format this correctly so that the start/ end/ recurstart etc all match formats i.e (YYYY-MM-DD) http://momentjs.com/docs/#/displaying/format/.

    9) Variable for the custom recurstart

    10) Variable for the custom recurend

    11) Use an IF statement to see weather the (theDate) falls between (recurstart) & (recurend) - log result

    12) Use ELSE statement to return the length>0 to hide other events that don't fall within that parameter.

    13) Non recurring events must have moment("match start date").startOf("month") & moment("match start date").endOf("month") otherwise they won't be visible.

提交回复
热议问题