Search code examples
jqueryfullcalendarfullcalendar-scheduler

FullCalendar - update resources businessHours


Need some help, with fullcalendar business hour update.

My code :

$.each(json_resource, function(index,value){

  var businessHours = { 
    dow: [ value.dow ], 
    start: value.start, 
    end: value.end 
  }

  // GET RESOURCE OBJECT
  var resourceObject = $('#calendar').fullCalendar( 'getResourceById', value.resourceId );

  // ADD NEW BUSINESS WORKING HOUR
  resourceObject.businessHours = businessHours;

  // UPDATE HOURS
  $('#calendar').fullCalendar( 'option', 'resources', resourceObject);

});

The problem is $('#calendar').fullCalendar( 'option', 'resources', events); it freeze windows for some seconds. Maybe there is another solution for updating resource business hours ?


Solution

  • I'm not sure why it would take several seconds to update, presumably that's some internal code of fullCalendar. You could try debugging the un-minified version to see where the delay is and maybe submit a bug to the maintainer.

    In the meantime, consider using Background Events for this purpose instead. You can achieve the same visual effect but vary the times by day exactly as you require, with no custom code - you could supply the data with the main event feed. See https://fullcalendar.io/docs/event_rendering/Background_Events for details