Uncaught ReferenceError: Modernizr is not defined at timeslots.js

Created on 15 February 2024, 10 months ago
Updated 19 February 2024, 10 months ago

Problem/Motivation

Uncaught ReferenceError: Modernizr is not defined at timeslots.js

When you load the timeslot widget on the order information page you get the above error.

I don't see that modernizer is loaded in the script

Maybe load it via a cdn?

<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script>
πŸ› Bug report
Status

Needs review

Version

1.1

Component

Code

Created by

πŸ‡ΏπŸ‡¦South Africa vlooi vlerke

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

Comments & Activities

  • Issue created by @vlooi vlerke
  • πŸ‡ΏπŸ‡¦South Africa vlooi vlerke

    Removing the call for Modernizer reveals more errors

    Uncaught TypeError: $context.find(...).once is not a function

    line 30: $context.find('input[data-drupal-date-format]').once('datePicker').each(function ()

    And

    Uncaught TypeError: $(...).find(...).findOnce is not a function

    Line:99 $(context).find('input[data-drupal-date-format]').findOnce('datePicker').datepicker('destroy');

    Remove jQuery dependency from the once feature β†’

  • Status changed to Needs review 10 months ago
  • πŸ‡ΏπŸ‡¦South Africa vlooi vlerke

    To Fix: Uncaught ReferenceError: Modernizr is not defined at timeslots.js

    Add:

    timeslots:
      js:
        js/timeslots.js: {}
      css:
        theme:
          css/timeslots.css: {}
      dependencies:
        - core/jquery
        - core/drupal.date
     +  - core/modernizr
        - jquery_ui_datepicker/datepicker
    

    To: commerce_timeslots.libraries.yml

    Clear cache.

    This will fix the error but the next error will apper

    Uncaught TypeError: $context.find(...).once is not a function

  • πŸ‡ΏπŸ‡¦South Africa vlooi vlerke

    to get rid of

    Uncaught TypeError: $context.find(...).once is not a function

    change line 30:

    $context.find('input[data-drupal-date-format]').once('datePicker').each(function ()

    to

    $(once('input[data-drupal-date-format]', 'datePicker', context.find)) .each(function () {
    

    This removes the error but it is not fixing the issue. Date picker is not loaded and a user can not select a date.

    tried adding - core/once as a dependency but did not work

Production build 0.71.5 2024