Getting Js error of calendar_options

Created on 1 June 2022, over 2 years ago
Updated 24 June 2024, 6 months ago

Getting calendar_options error in fullcalendar_view.js, seems like it is traversing every calendar, and it is not able to find calendar.

🐛 Bug report
Status

Closed: works as designed

Version

5.1

Component

Code

Created by

🇮🇳India manojbisht_drupal

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇦🇺Australia mingsong 🇦🇺

    What error messages in the browser console?
    Steps to reproduce it?

  • 🇵🇰Pakistan hamza_niazi

    This error comes after the migration i have done migration of my drupal from 9.5.10 to 10.0.11 my full calendar is not loading and is throwing the error of the calendar_option in console

  • 🇦🇺Australia mingsong 🇦🇺

    Try to re-save your view setting.

    Particularly the options you mentioned in your console, you need to double check the setting for it. Then save the view.

  • 🇬🇧United Kingdom darren.fisher

    Same here. Steps to reproduce. Having already created a fullcalendar_view display for a view using version 5.1.10 upgraded module to 5.1.13 and saw a console error:

    Uncaught TypeError: Cannot read properties of undefined (reading 'calendar_options')
    at HTMLDivElement. (fullcalendar_view.js?s29kk4:286:53)
    at Function.each (jquery.min.js?v=3.6.3:2:3003)
    at E.fn.init.each (jquery.min.js?v=3.6.3:2:1481)
    at buildCalendars (fullcalendar_view.js?s29kk4:282:6)
    at fullcalendar_view.js?s29kk4:390:7

    Tried editing the view and re-saving the format display and settings but the error persists. The patch in #7 fails to apply.

  • 🇬🇧United Kingdom darren.fisher

    Reverting to 5.1.12 fixed my issue for now.

  • 🇺🇸United States webdrips

    Same as @darren.fisher #12, reverting to 5.1.12 fixed the issue for me.

    I have an exposed taxonomy filter if it matters to help reproduce.

  • 🇦🇺Australia mingsong 🇦🇺

    Did you clear all caches after updating to 5.1.13?

  • 🇦🇺Australia mingsong 🇦🇺

    Is there PHP error/warning in your logs?

    In JS, only one line where the 'calendar_options' is read.

    https://git.drupalcode.org/project/fullcalendar_view/-/blob/5.x/js/fullc...

    Could you print out or debug the 'viewSettings' variable in the line above to see what values that variable has?

  • 🇦🇺Australia mingsong 🇦🇺

    Clear all caches is critical after updating a Drupal module. Particularly a new version of a Drupal module that modified a template.

    Back to the latest release (5.1.3) of this module, W3C Validator: Attribute calendar-view-* not allowed on element div at this point. Fixed changes the view template. Therefore, if you didn't clear all caches and hard-reload your calendar page. The error will occur.

  • 🇷🇴Romania stefan.butura

    Can confirm that I also had this issue and rolling back to 5.1.12 fixed it.

  • 🇺🇸United States dlfaison

    Reverting back to 5.1.12 resolved my issue as well.

  • Status changed to Active about 1 year ago
  • 🇺🇸United States webdrips

    Definitely cleared the cache; Drupal 10.1.6 PHP 8.1.24

    Steps to re-produce: Upgrade this module from 5.1.12 to 5.1.13

    See related screenshots.

  • 🇺🇸United States webdrips

    Adding the requested debugging, and there are no errors/warnings in the log.

  • 🇺🇸United States webdrips

    Providing a patch for now in case anyone wants to use the latest version of the module.

  • 🇦🇺Australia mingsong 🇦🇺

    Thanks @Dan Harris.

    Could you do me a favour? Could you please inspect your view output and to check the following html element attribute for me?

    • data-calendar-view-index
    • data-calendar-view-name
    • data-calendar-display

    For example, I used Firefox develop tool to inspect my view output, then here is what I saw.

  • 🇦🇺Australia mingsong 🇦🇺

    Thanks for the patch #21,

    Since that patch just rolled back what we did for W3C Validator: Attribute calendar-view-* not allowed on element div at this point. Fixed , that patch won't be ported to a new version in the future.

    I am still trying to work out what exactly cause this issue to your sites. My site is totally fine with 5.1.13.

    Till October 22, 2023, there are 6,647 sites using 5.1.13. I don't think they are all new installation. Pretty sure some of those sites were upgraded from 5.1.12 and working fine.

    Given that, I am assuming this is a edge case.

    Again I am happy to help figure out what happened, but need more information.

  • Status changed to Postponed: needs info about 1 year ago
  • 🇦🇺Australia mingsong 🇦🇺
  • 🇺🇸United States webdrips

    @Mingsong I don't seem to have any of those divs in my output.

    In fact, I don't see the proper template at all. I see views-view.html.twig, but the fullcalendar template is never used.

  • 🇦🇺Australia mingsong 🇦🇺

    Right, I think there is a template conflict to your site.

    The line 27 in the view template is critical for your calendar working.

    https://git.drupalcode.org/project/fullcalendar_view/-/blob/5.1.13/templ...

    If your custom theme/module override that template to inject your own business logic, that is totally fine. But you have to make sure your custom them/template has the html attribute required. Otherwise, it won't work.

    I did a quick test by installing 5.1.12 on a brand new site, and then created a Fullcalendar view by using 5.1.12.

    After that, I updated the module to 5.1.13, cleared the cache. The view is working well. So now I can tell, it is working as design.

    The html markup after updating to 5.1.13

  • Status changed to Closed: works as designed about 1 year ago
  • 🇦🇺Australia mingsong 🇦🇺

    I close it as I believe this issue does not come from this module.

    If your theme/module override the calendar view template, you have to make sure following template variables available to your view template and appropriate populated.

    * - options: View plugin style options:
    * - classes: CSS classes.
    * - defaultDate: Default date of the calendar
    * - start: Field name of start date
    * - end: Field name of end date
    * - languageSelector: Flag for the language dropdown box
    * - view_index: View index
    * - view_id: The id of the view
    * - display_id: The view display id
    * - showAddEvent: Show add event button
    * - entity_id: The Entity type machine name

    For example, your template must have the following line.

    <div class="js-drupal-fullcalendar" data-calendar-view-index="{{ view_index }}" data-calendar-view-name="{{ view_id }}" data-calendar-display="{{ display_id }}">
    </div>
    
  • 🇺🇸United States webdrips

    Okay yep that was it. Anyone using their own override of views-view-fullcalendar.html.twig must make sure to update it.

    Specifically, you want to make sure these lines are use the proper html attributes:

    <div class="js-drupal-fullcalendar" data-calendar-view-index="{{ view_index }}" data-calendar-view-name="{{ view_id }}" data-calendar-display="{{ display_id }}"></div>
    <select id='locale-selector-{{ view_index }}' data-calendar-view-index="{{ view_index }}"></select>
    

    If you're using the old template override, you will have this (or something you overrode) instead:

     <div class="js-drupal-fullcalendar" calendar-view-index="{{ view_index }}" calendar-view-name="{{ view_id }}" calendar-display="{{ display_id }}"></div>
    <select id='locale-selector-{{ view_index }}' calendar-view-index="{{ view_index }}"></select>
    

    @Mingsong perhaps it would be helpful to let people know when upgrading the module to check if that file is being overridden with some sort of status message.

  • 🇦🇺Australia mingsong 🇦🇺

    Exactly.

    Take the change to the twig file as example.

    https://git.drupalcode.org/project/fullcalendar_view/-/commit/fb6e78c773...

    I will update the release note for 5.1.13 to notify it.

    Thanks for helping.

  • 🇬🇧United Kingdom darren.fisher

    Just dropping in to confirm #28 fixes the issue! Thanks.

Production build 0.71.5 2024