FullCalendar JavaScript API

Last updated on
30 April 2025

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

Adding custom JavaScript

Replace all instances of "custom_module" with the name of your module.


/**
 * Implements hook_fullcalendar_api().
 */
function custom_module_fullcalendar_api() {
  return array(
    'api' => fullcalendar_api_version(),
  );
}

/**
 * Implements hook_fullcalendar_options_info().
 */
function custom_module_fullcalendar_options_info() {
  return array(
    'custom_module' => array(
      'js' => TRUE,
      'no_fieldset' => TRUE,
      'weight' => 5,
    ),
  );
}

NOTE: You must name your JS file custom_module.fullcalendar.js, and place it in a subfolder of your module named js so what you have is /modules/custom_module/js/custom_module.fullcalendar.js.

(function($) {
Drupal.fullcalendar.plugins.custom_module = {
  options: function (fullcalendar, settings) {
    return {
      eventClick: function(events) {
        return false;
      }
    };
  }
};
}(jQuery));

Only display business hours

(function($) {
Drupal.fullcalendar.plugins.custom_module = {
  options: function (fullcalendar, settings) {
    return {
      weekends: false,
      minTime: 9,
      maxTime: 17
    };
  }
};
}(jQuery));

Change view by clicking on a day

(function($) {
Drupal.fullcalendar.plugins.custom_module = {
  options: function (fullcalendar, settings) {
    return {
      dayClick: function(date, allDay, jsEvent, view) {
        $('.fullcalendar', fullcalendar.$calendar)
          .fullCalendar('gotoDate', date)
          .fullCalendar('changeView', 'agendaDay');
      }
    };
  }
};

}(jQuery));

Make the calendar more European

(function($) {
Drupal.fullcalendar.plugins.fc_tweaks = {
  options: function (fullcalendar, settings) {
    return {
         
      // formatting dates at the top of columns
      columnFormat: { month: 'ddd',         // Fri
                      week: 'ddd dS',       // Fri 13th
                      day: 'dddd dS MMMM'   // Friday 13th September
                    },
      
      timeFormat: {
        
        // for agendaWeek and agendaDay
        agenda: 'H:mm{ - H:mm}',            // 5:00 - 16:30 -- if you want 05:00 use "HH:00"        
        // for all other views
        '': 'h:mmtt{ - h:mm}tt',            // 7:00pm -- friendly initial month view
        },
      
      // agenda time column  
      axisFormat: 'HH:mm',
      
      // formatting titles  
      titleFormat: {
        month: 'MMMM yyyy',                              // September 2013
        week: "MMM dS[ yyyy]{ '—'[ MMM] dS yyyy}", // Sep 9th - 15th 2013
        day: 'dddd, dS MMM, yyyy',                       // Tuesday, 13th Sep, 2009
        }
              
    };
  }
};
}(jQuery));

Help improve this page

Page status: Not set

You can: