drupalSettings is not defined error when using colorbox

Created on 21 March 2023, over 1 year ago
Updated 18 April 2023, about 1 year ago

Problem/Motivation

We are using the 7.x-2.7 version with the Google Analytics 4 patches and noticed that colorbox popups are throwing JavaScript errors. Here is the error and the line in the source https://git.drupalcode.org/project/google_analytics/-/blob/7.x-2.7/googl....

Best seen if you have colorbox setup but I don't think the issue is caused by colobox. I think the variable 'drupalSettings' is not being loaded correctly.

Uncaught ReferenceError: drupalSettings is not defined
    at HTMLDocument.<anonymous> (googleanalytics.js?rrw0pp:82:16)
    at HTMLDocument.dispatch (jquery.min.js?v=1.8.3:2:38053)
    at HTMLDocument.u (jquery.min.js?v=1.8.3:2:33916)
    at Object.trigger (jquery.min.js?v=1.8.3:2:36647)
    at HTMLDocument.<anonymous> (jquery.min.js?v=1.8.3:2:44416)
    at Function.each (jquery.min.js?v=1.8.3:2:14543)
    at $.fn.init.each (jquery.min.js?v=1.8.3:2:11217)
    at $.fn.init.trigger (jquery.min.js?v=1.8.3:2:44392)
    at trigger (jquery.colorbox-min.js?v=1.3.25:6:4422)
    at complete (jquery.colorbox-min.js?v=1.3.25:6:14752)

Proposed resolution

I think the google analytics JavaScript needs to load 'drupalSettings' in the initial function setup. Is it maybe a Drupal 9 feature and not something available in Drupal 7?

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dmundra Eugene, OR

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

Comments & Activities

Production build 0.69.0 2024