【问题标题】:Recurring event in FullCalendarFullCalendar 中的重复事件
【发布时间】:2017-11-27 10:49:28
【问题描述】:

因此,我在过去 2 周里一直在试图弄清楚这一点,并尝试了所有其他之前提出的答案。我仍然无法正确处理。

我正在尝试设置一个日历,在其中过滤指定日期范围内的重复事件。 示例:“我的活动” - 每周四下午 2:15 - 2017/06/01 和 2017/06/30 之间。

我没有成功尝试过此链接中提出的解决方案: Recurring Events in FullCalendar

最后我决定走这条路: https://github.com/c-trimm/moment-recur

它是一个应该处理日期范围过滤器的时刻.js 插件 (moment-recur)。

请帮忙!

我的 json 提要返回:

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

我的日历可以正常工作,只是它不会永远停止在星期四发布活动。我不想手动复制事件。

<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>

我相信我想把它写成一个函数,但无论我尝试什么,它要么会破坏日历,要么不会返回任何结果。在此先感谢大家!

【问题讨论】:

标签: javascript fullcalendar date-range recurring-events moment-recur


【解决方案1】:

以下是完整日历中重复事件的提琴手链接。

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

您需要在事件中指定dow 属性,如示例中指定的那样。

$('#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
    }],
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多