简体   繁体   中英

Recurring event in FullCalendar

So I have spent the past 2 weeks trying to figure this out and tried all other previously proposed answers. I'm still not able to get it right.

I'm trying to setup a calendar where the recurring events are filtered within the specified date range. Example: "My event" - every Thursday at 2:15PM - Between 2017/06/01 and 2017/06/30.

I've unsuccessfully tried the solutions proposed on this link: Recurring Events in FullCalendar

In the end end I decided to follow this route: https://github.com/c-trimm/moment-recur

It's a moments.js plugin (moment-recur) that should process the date range filter.

Please help!

My json feed returns:

  [{
    "title":"my event",
    "start":"2017-06-01T14:15",
    "dow":"4",
    "recurrence":"moment().recur[{
                 start:\"2017-06-01\",
                 end:\"2017-06-30\"}]"
  }]

My calendar works except for the fact that it will not stop publishing the event on Thursdays forever. I don't want to have to manually duplicate the event.

<link rel="stylesheet" type="text/css" href="/fullcalendar.css">
    <script src='/jquery.min.js'></script>
    <script src='/moment.min.js'></script>
    <script src='/moment-recur.js'></script>
    <script src='/fullcalendar.js'></script>    

    <script>

        $(document).ready(function() {

            $('#calendar').fullCalendar({
                header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,listWeek,listDay'
                },
                validRange: function(nowDate) {
                        return {
                            start: nowDate.clone().subtract(2, 'months'),
                            end: nowDate.clone().add(2, 'months')
                        };
                    },

                // customize the button names,
                // otherwise they'd all just say "list"
                views: {
                listDay: { buttonText: 'Day' },
                listWeek: { buttonText: 'Week' },
                },
                hiddenDays: [ 5 ], // hide Fridays
                editable: true,
                eventLimit: true, // allow "more" link when too many events
                businessHours: [ // specify an array instead
                    {
                        dow: [ 1 ], // Monday,
                        start: '12:30', // 8am
                        end: '22:00' // 6pm
                    },
                    {
                        dow: [ 2, 3 ], // Tuesday, Wednesday
                        start: '9:30', // 8am
                        end: '22:00' // 6pm
                    },
                    {
                        dow: [ 4, ], // Thursday
                        start: '13:00', // 10am
                        end: '22:00' // 4pm
                    },
                    {
                        dow: [ 7 ], // Sunday
                        start: '11:00', // 10am
                        end: '18:30' // 4pm
                    }],
                events: 'my-event/feed',

       //THIS IS WHERE I GET STUCK!!!!!

                // I'm trying to implement this:
                eventRender: 
                recurrence = moment().recur({
                start: "01/01/2014",
                end: "01/01/2015"
               });

            });
        });
    </script>

    <div id='calendar'></div>

I believe i'm suppose to write it as a function but no mater what I try it either brakes the calendar or doesn't return any results. Thanks in advance to you all!

Below is the fiddler link for recurring events in fullcalendar.

http://jsfiddle.net/slicedtoad/duu0dx2t/1/

You need to specify dow property in event as specified in example.

$('#calendar').fullCalendar({
    defaultDate: moment(),
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },
    defaultView: 'month',

    events: [{
        title:"My repeating event",
        start: '10:00', // a start time (10am in this example)
        end: '14:00', // an end time (6pm in this example)

        dow: [ 1, 4 ] // Repeat monday and thursday
    }],
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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