简体   繁体   English

带有 rrule 的 Fullcalendar 重复事件不起作用

[英]Fullcalendar recurring event with rrule is not working

I am using fullcalendar 4.4.0 and everything working fine except rrule.我正在使用 fullcalendar 4.4.0,除 rrule 外,一切正常。 If i try with simple recurrence, it is working, but rrule recurrence not working.如果我尝试简单的重复,它会起作用,但规则重复不起作用。 let me share my code让我分享我的代码

    <script src="https://unpkg.com/@fullcalendar/rrule@4.4.0/main.min.js"></script>
    <script src="https://unpkg.com/@fullcalendar/core@4.4.0/main.min.js"></script>
    <script src="https://unpkg.com/@fullcalendar/interaction@4.4.0/main.min.js"></script>
    <script src="https://unpkg.com/@fullcalendar/daygrid@4.4.0/main.min.js"></script>
    <script src="https://unpkg.com/@fullcalendar/timegrid@4.4.0/main.min.js"></script>
    <script src="https://unpkg.com/@fullcalendar/resource-common@4.4.0/main.min.js"></script>
    <script src="https://unpkg.com/@fullcalendar/resource-daygrid@4.4.0/main.min.js"></script>
    <script src="https://unpkg.com/@fullcalendar/resource-timegrid@4.4.0/main.min.js"></script>
    <scritpt src="https://unpkg.com/@fullcalendar/moment@4.4.0/main.min.js"></scritpt>
    <script src="https://unpkg.com/@fullcalendar/interaction@4.4.0/main.min.js"></script>
    <script src="{{asset('public/plugins/datepicker-master/dist/datepicker.js')}}"></script>

The code for generating event is as follows.生成事件的代码如下。

             function makeEventFromBook(book) {
                var event={};
                var start_time_object=new Date(book.start_date+" "+book.book_time);
                var end_time_object=new Date(start_time_object.getTime() + 
                parseInt(book.duration)*60*1000);
                var start_time=start_time_object.toISOString();
                var end_time=end_time_object.toISOString();
                if(book.name==='null' || book.name==null)
                    book.name='';
                event={
                        id:book.id,
                        resourceId: book.provider_id,
                        // start: start_time,
                        // end:end_time,
                        title:book.name,
                        overlap:false,
                        backgroundColor:`${book.service_item_id==0 ? '#ff0000' :  '#1f1dd0'} `,
                        textColor:'#fff',
                        borderColor:'transparent',

                        rrule: {
                            count: 13,
                            freq: 'weekly',
                            interval: 1,
                            byweekday: [ 'mo', 'fr' ],
                            dtstart: '2020-03-01',
                            duration:"01:30"
                        },
                        groupId:book.id,

                        extendedProps:{
                            user_id:book.user_id,
                            user_name:book.user_name,
                            user_email:book.user_email,
                            user_phone_number:book.user_phone_number,
                            duration:book.duration,
                            book_date:book.book_time,
                            from_admin:book.from_admin,
                            service_type:book.service_type,
                            service_item_id:book.service_item_id,
                            provider_id:book.provider_id,
                            comment:book.comment,


                        }
                }
                return event;
            }

What is issue here?这里有什么问题? If anyone has experience, please help me.如果有人有经验,请帮助我。

I am sharing my calendar how it is being showed我正在分享我的日历显示方式在此处输入图片说明

There is no recurring event here.这里没有重复发生的事件。

Example of event data:事件数据示例:

events=[ { id: 117, resourceId: 3, title: "Personal", backgroundColor: "#ff0000 ", rrule: { count: 13, freq: "weekly", interval: 1, byweekday: [ "mo", "fr" ], dtstart: "2020-03-01", duration: "01:30" }, groupId: 117 }, ]

You need to make sure you include the rrule Javascript library file, and the fullCalendar rrule plugin file, and include the plugin in your calendar config.您需要确保包含 rrule Javascript 库文件和 fullCalendar rrule 插件文件,并将该插件包含在您的日历配置中。

You also need to remove the "duration" property from your rrule, because that's not a valid rrule option, and will cause an error.您还需要从 rrule 中删除“duration”属性,因为这不是有效的 rrule 选项,并且会导致错误。

At the time of writing, you can get the rrule file from https://cdn.jsdelivr.net/npm/rrule@2.6.2/dist/es5/rrule.min.js在撰写本文时,您可以从https://cdn.jsdelivr.net/npm/rrule@2.6.2/dist/es5/rrule.min.js获取 rrule 文件

Here's a working demo: https://codepen.io/ADyson82/pen/poJWLzB这是一个工作演示: https : //codepen.io/ADyson82/pen/poJWLzB

Demo code, for reference:演示代码,供参考:

document.addEventListener("DOMContentLoaded", function() {
  var calendarEl = document.getElementById("calendar");
  var calendar = new FullCalendar.Calendar(calendarEl, {
    plugins: ["interaction", "dayGrid", "timeGrid", "resourceTimeline", "rrule"],
    header: {
      left: "prev,next today",
      center: "title",
      right: "dayGridMonth,timeGridWeek,timeGridDay"
    },
    events: [ { id: 117, resourceId: 3, title: "Personal", backgroundColor: "#ff0000 ", rrule: { count: 13, freq: "weekly", interval: 1, byweekday: [ "mo", "fr" ], dtstart: "2020-03-01" }, groupId: 117 } ]
  });

  calendar.render();
});

I have faced this issue!I was working with @fullcalendar/ @5.1.0 (ie.,@fullcalendar/core, @fullcalendar/rrule and so on) , the recurring events didn't display.我遇到过这个问题!我正在使用@fullcalendar/@5.1.0(即@fullcalendar/core、@fullcalendar/rrule 等),重复事件没有显示。 Then I changed all my fullcalendar dependencies (@fullcalendar/) to @5.2.0 and used rrule @2.6.4.然后我将所有 fullcalendar 依赖项 (@fullcalendar/) 更改为 @5.2.0 并使用 rrule @2.6.4。 It is working fine!它工作正常!

You can use the code below to show a day, daily, weekly, every two weeks and monthly events with a tooltip on mouse hover event.您可以使用下面的代码显示一天、每天、每周、每两周和每月的事件,带有鼠标悬停事件的工具提示。

In this example you can see how we can set up rrule in FullCalendar .在这个例子中,你可以看到我们如何在 FullCalendar 中设置规则

Visit here- https://stackoverflow.com/a/68770685/9673996访问这里 - https://stackoverflow.com/a/68770685/9673996

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

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