Cookie popup appears only on my admin theme, in the main theme I have the error "jQuery is not defined".

I use jQuery Update and it seems to work... so why I have this error?

Comments

smurfxx created an issue. See original summary.

voj’s picture

Priority: Normal » Minor
Status: Active » Postponed (maintainer needs more info)

Could you provide more details?

can you open the console of your browser and maybe send a screenshot?

aheredia’s picture

Hi
As a workaround, if they are in different scope try to change the scope to header instead of footer on drupal_add_js in the .module

drupal_add_js(array('eu_cookie_compliance' => $data['variables']), array('type' => 'setting', 'scope' => 'header'));

drupal_add_js(drupal_get_path('module', 'eu_cookie_compliance') . '/js/eu_cookie_compliance.js', array('type' => 'file', 'scope' => 'header'));

aheredia’s picture

If they are in the same scope you only need to add more weight to the js file.

Try with the hook_js_alter();

svenryen’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev

Can I just confirm, are you using version 2.x or 1.x? We're currently not using 2.x since we're not planning to implement any feature that breaks backwards compatibility. If you're on 2.x, please use a stable release of 1.x instead.

Echofive’s picture

Hello,

I use the version 7.x-2.7 of jQuery Update (1445379855) and the version 7.x-1.14 of EU Cookie Compliance (1400592528) and I have the same error. The version of Jquery is the 1.10 (minified) and it works on the admin theme only.

If I change the scope from "footer" to "header" (lines 124 and 126 of the .module), it shown on the front theme, independently of the value of the setting "Place the pop-up at the top of the website".

So, when jQuery Update is used, the scope must be "header", and I can't explain why at this time.

Kind regards,

Echofive

Echofive’s picture

Here a patch, for people that need it, to change the scope of the script from "footer" to "header".

svenryen’s picture

Thanks for the patch. I need to do some testing to ensure this fix for jQuery Update doesn't break anything else.

aheredia’s picture

The patch at #7 it is exactly what i commented at #3 that was working for me.

So great.
Thanks

svenryen’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

This has been fixed in dev and soon to be released 1.15 (just need to work through some more issues to clear the queue). There's now an option for the script to be output in the header.

heyyo’s picture

Category: Support request » Bug report
Priority: Minor » Normal
Status: Closed (duplicate) » Needs review
StatusFileSize
new715 bytes

I think I found the reason why the scope was requested to be in header when using JQuery Update.
The code to replace the library jquery.cookie file by the version 1.4.1 seems to be incorrect.
The key 'data' as far I understood is reserved for Javascript specific settings.
https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func...

With this modification, I don't need to add the javascript in header.

svenryen’s picture

Thanks for catching this. I checked in XDebug and you're spot on about the syntax. Just a small remark: for d7 contrib we have to use old school array syntax, since D7 also runs on PHP5.3.

  • svenryen committed 2ca02a4 on 7.x-1.x authored by heyyo
    Issue #2718281 by svenryen, heyyo: jQuery is not defined
    
svenryen’s picture

Status: Needs review » Fixed
heyyo’s picture

Status: Fixed » Active

Sorry I think this modification wasn't necessary.
Now I had a deeper look, when using the Jquery update module and the last dev, 2 different versions of jquery.cookie is added to the page.
The one of this module and the one provided by jquery update module.

Without the last patch, only the jquery.cookie loaded is the one of the jquery update module.
Because the hooh_library_later of jquery update is runned after the one of this module.

To change this behavior, I suppose we need to increase the weight of this module to one higher than jquery_update if it is installed.

heyyo’s picture

  • svenryen committed 31e5740 on 7.x-1.x authored by heyyo
    Issue #2718281 by heyyo, svenryen: jQuery is not defined
    
svenryen’s picture

Status: Active » Fixed

Thanks for the patch. It's added to -dev.

  • svenryen committed 2ca02a4 on 7.x-2.x authored by heyyo
    Issue #2718281 by svenryen, heyyo: jQuery is not defined
    
  • svenryen committed 31e5740 on 7.x-2.x authored by heyyo
    Issue #2718281 by heyyo, svenryen: jQuery is not defined
    
  • svenryen committed a44ca28 on 7.x-2.x
    Merge branch '7.x-1.x' into 7.x-2.x
    
    * 7.x-1.x:
    Issue #2965976 by...

Status: Fixed » Closed (fixed)

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

marco.falconi’s picture

Hi,
I'm having the same issue in my live website (https://www.sardegnafuoritraccia.it/) after updating modules and core.

I update also the "EU Cookie Compliance" module to the last dev version but the error remains.
Any suggestion?

Thanks

marco.falconi’s picture

Hi,
I solved the problem exposed in #21.
The problem was the varialbe $scripts printed after the variabile $page_bottom in my html-tpl.php.
Printing $scripts before $page_bottom solved the problem.
Regards