Problem/Motivation

We need to replace jQuery.once() with javascript once() in Drupal 10.

Error in hubspot_integration.js file

Uncaught TypeError: $(...).once is not a function
at Object.attach (hubspot_integration.js?v=1.x:4:26)
at drupal.js?v=10.0.10:166:24
at Array.forEach ()
at Drupal.attachBehaviors (drupal.js?v=10.0.10:162:34)
at drupal.init.js?v=10.0.10:32:12
at HTMLDocument.listener (drupal.init.js?v=10.0.10:20:7)

Proposed resolution

   $(once('hubspot_integration', 'html', context)).each(function () {
          //.......
       }
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rishabjasrotia created an issue. See original summary.

rishabjasrotia’s picture

StatusFileSize
new694 bytes
rishabjasrotia’s picture

Status: Active » Needs review
sarwan_verma’s picture

StatusFileSize
new851 bytes

Hi,
I have fixed this issue Drupal 10 Jquery Once Error and also attached patch.

romainj made their first commit to this issue’s fork.

romainj’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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