Search code examples
fullcalendarfullcalendar-scheduler

Option to just use days in the week with fullcalendar library


I am using the Fullcalendar library, and I have an array of JavaScript objects:

arr = [{"monday":{"start_time":9,"end_time":10.5},"title":"English for Beginer"},{"tuesday":{"start_time":8.5,"end_time":10},"title":"English for Beginer"},{"wednesday":{"start_time":8.5,"end_time":10},"title":"English for Beginer"}]

According to the doc, I can set up my event sources like this:

{
    events: [
        {
            title: 'Event1',
            start: '2011-04-04T09:30',
            end: '2011-04-04T10:30',

        },
        {
            title: 'Event2',
            start: '2011-05-05T9:30',
            end: '2011-04-04T10:30',
        }
        // etc...
    ],
    color: 'yellow',   // an option!
    textColor: 'black' // an option!
}

However, I only have the days in a week in my JavaScript objects, like monday, tuesday, wednesday, etc as you can see. Therefore, I am wondering if there is a way for me to configure my event sources like the following:

{
        events: [
            {
                title: 'Event1',
                start: 'MondayT09:30',
                end: 'MondayT10:30',

            },
            {
                title: 'Event2',
                start: 'TuesdayT9:30',
                end: 'TuesdayT10:30',
            }
            // etc...
        ],
        color: 'yellow',   // an option!
        textColor: 'black' // an option!
    }

I have been looking for a solution for a while, but still can't find one. Any suggestions or idea would be appreciated.


Solution

  • without date set in event.start variable fullcalendar will not be able to display your event. Please see fullCalendar documentation

    Event.Start date is required field. Your JSON needs some information about date when your event starts.

    When you want to create recurring event, you can use event.dow parameter like this:

    events: [
      {
        title: 'All Day Event',
        start: '2017-05-22'
      }, 
            {
        title: 'Sviatok práce',
        start: '00:00 ',
        end: '24:00',
              dow: [1,2,3,4,5]
      },