My custom module doesn't work. I need help.
I try to have dayClick option like in fullcalendar documentation -> javascript API

fullcalendar_yoh.info

name = fullcalendar yoh
description = Module perso de Yoh
core = 7.x
package = FullCalendar
dependencies[] = fullcalendar

fullcalendar_yoh.module

<?php

/**
* Implements hook_preprocess_views_view().
*/
function fullcalendar_yoh_preprocess_views_view(&$variables, $hook) {
  if ($variables['view']->display_handler->get_option('style_plugin') == 'fullcalendar') {
    drupal_add_js(drupal_get_path('module', 'fullcalendar_yoh') . '/js/fullcalendar_yoh.js');
  }
}

js/fullcalendar_yoh.js

(function($) {
Drupal.fullcalendar.plugins.fullcalendar_yoh = {
  options: function (fullcalendar) {
    var options = {
      dayClick: function(date, allDay, jsEvent, view) {
        $('.fullcalendar')
          .fullCalendar('gotoDate',date)
          .fullCalendar('changeView','basicDay');
      }
    };
	return options;
  }
};
}(jQuery));

If i change Drupal.fullcalendar.plugins.fullcalendar_yoh to Drupal.fullcalendar.plugins.fullcalendar_option or Drupal.fullcalendar.plugins.fullcalendar in my js file, dayClick works but fullcalendar params or fullcalendar options modules params are overwriting.

Comments

tim.plunkett’s picture

Title: Made a custom module » Update FullCalendar custom plugin documentation
Component: Code » Documentation
Category: support » task
Status: Active » Needs review

The documentation somehow got out of date, sorry about that.

Your .info file is fine, here is the new .module file:

<?php

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

/**
 * Implements hook_fullcalendar_option_info().
 */
function fullcalendar_yoh_fullcalendar_option_info() {
  return array(
    'fullcalendar_yoh' => array(
      'name' => t('FullCalendar Yoh'),
      'js' => TRUE,
      'no_fieldset' => TRUE,
      'weight' => 5,
    ),
  );
}

The JS file should be js/fullcalendar_yoh.fullcalendar.js, and there is one small change:

(function($) {

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

}(jQuery));

Note the $('.fullcalendar', fullcalendar.$calendar), the added part ensures that the change is made to the correct calendar if there are more than one per page. However, if you want a click on one to change both, use your original code.

yooh’s picture

Thanks a lot, it's working.
Now, i can try more difficult :)
See you later!

aspilicious’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.