Javascript error: Uncaught ReferenceError: once is not defined

Created on 25 July 2023, over 1 year ago
Updated 27 June 2024, 6 months ago

Using the tabs paragraph type, its associated javascript contains (jQuery, Drupal, once); which, as I understand, has been removed from Drupal.

So the console says "Uncaught ReferenceError: once is not defined" and the script is not executed

💬 Support request
Status

Closed: cannot reproduce

Version

1.0

Component

Code

Created by

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

Comments & Activities

  • Issue created by @drupaldope
  • Assigned to keshavv
  • Issue was unassigned.
  • 🇮🇳India mukhtarm

    hi @DrupalDope Can you please elaborate the issue by specifying the "Steps to reproduce"?

  • I'm on Drupal 9.5.10 , sorry, forgot to state the version

    the error went away after I added the dependency core/once to that paragraph's library.yml file

  • 🇮🇳India mukhtarm

    Yea sure , if you are using the version "drupal/w3css_paragraphs": "^1.0",

    its already there :

    w3css-paragraphs-admin-seven:
      version: VERSION
      css:
        theme:
          css/w3css-color-libraries-classes.css: { }
          css/w3css-paragraphs-admin-seven.css: { }
      js:
        js/w3css-paragraphs-admin-seven.js: { }
      dependencies:
        - core/jquery
        - core/drupal
        - core/once
    
    w3css-paragraphs-admin-claro:
      version: VERSION
      css:
        theme:
          css/w3css-color-libraries-classes.css: { }
          css/w3css-paragraphs-admin-claro.css: { }
      js:
        js/w3css-paragraphs-admin-claro.js: { }
      dependencies:
        - core/jquery
        - core/drupal
        - core/once
    
    w3css-paragraphs:
      version: VERSION
      css:
        theme:
          css/w3css-color-libraries-classes.css: { }
          css/w3css-color-active-classes.css: { }
          css/w3css-paragraphs-base.css: { }
      js:
        js/w3css-paragraphs-base.js: { }
    

    glad that its resolve, btw

  • thanks, but I was using 1.0.13, and it was not there, even after a composer update --with-all-dependencies

    I added the lines into /modules/contrib/w3css_paragraphs/modules/w3css_paragraphs_tabs/w3css_paragraphs_tabs.libraries.yml

  • Assigned to flashwebcenter
  • Status changed to Closed: works as designed over 1 year ago
  • 🇺🇸United States flashwebcenter Austin TX

    Hello,

    The w3css paragraphs is always used with the w3css theme. If you are doing any custom work, you should copy all the w3css js dependencies to the theme or module. The theme load all in drupal8_w3css_theme.libraries.yml line 73.

    The demo site has six Accordion examples all are working fine. The is built with D10.

    Best wishes,
    Alaa

  • Status changed to Closed: cannot reproduce over 1 year ago
  • 🇺🇸United States flashwebcenter Austin TX
  • Thank you @flashwebcenter
    Indeed, I was using the paragraphs inside another theme.
    I will try what you suggested.

    However, if it's just a question of adding the libraries to each paragraph wouldn't it be useful if the paragraphs worked with other themes as well ?
    It might greatly expand the number of users of the module.

  • 🇺🇸United States flashwebcenter Austin TX

    @DrupalDope, I agree. I will add this to do list.
    Best wishes,
    Alaa

  • 🇺🇸United States flashwebcenter Austin TX
Production build 0.71.5 2024