Repeat events on FullCalendar base on date start and end

时间:2017-12-18 06:00:28

标签: php jquery laravel fullcalendar

By default, FullCalendar stretches the event base on the starting date up to end date. For example,

{
"title": "2",
"start": "2017-12-17",
"end": "2017-12-20",
"icon": "fa-truck"
},

enter image description here

My problem is kinda similar here Recurring Events in FullCalendar, but this one uses time and days of week.

What I want is that the event "Truck" will keep appearing every date, from 2017-12-17, 2017-12-18, 2017-12-19, 2017-12-20.

This is my code.

function calendar(data){
        $('#calendar').fullCalendar({
             events: data,
             eventRender: function(event, element) {
                  if(event.icon){          
                     element.find(".fc-event-title").prepend("<i class='fa "+event.icon+"'></i>");
                  }
               }
        });
    }   

1 个答案:

答案 0 :(得分:2)

Generate server side code which will return you json in following format. You can cross check this using javascript as well with hard values.

{
"title": "2",
"start": "2017-12-17",
"end": "2017-12-17",
"icon": "fa-truck"
},
{
"title": "2",
"start": "2017-12-18",
"end": "2017-12-18",
"icon": "fa-truck"
},
{
"title": "2",
"start": "2017-12-19",
"end": "2017-12-19",
"icon": "fa-truck"
},

AND so on...

You can assign above json to data var and check. and then update the server side code.