When I click on the Preview button in the add/edit node page. I get the following Firebug message:

$.cookie is not a function
http://localhost/drupal7/misc/tabledrag.js?ldbu1k
Line 168

I made some tests and I detect that this error is produced when in the add/edit node page there are one or more fields with unlimited possible values and the node form is in an overlay.

For example, when the URL is http://localhost/drupal7/node/7#overlay=node/7/edit, the Javascript error appears, but not in http://localhost/drupal7/node/7/edit

Regards

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

droplet’s picture

Version: 7.0-rc2 » 7.x-dev
Priority: Minor » Major

I'm not familiar with new API. what I seem is when the toolbar enabled, it loads jquery.cookie into page. When tabledrag called to load jquery.cookie, for some reason.. it prevent to load twice.

but overlay loading in iframe which do not share with same JS.

It's very common feature, affect lots user & cause usability issues

catch’s picture

Component: field system » overlay.module

Moving to overlay.

unik’s picture

I have the same error message ($.cookie is not a function) pointing at line 168 of tabledrag.js every time i try to order items by handler but in my case it hapens even without the overlay (e.g. I get it in both #overlay=admin/structure/block and admin/structure/block pages).
Error exists even with both toolbar and overlay modules disabled so maybe this is not so overlay related?

...or I am in the wrong issue? :/

droplet’s picture

@unik,
same issue

unik’s picture

Is there any possibility that filenames like jquery.cookie.js cause this kind of errors?
I just discover that my server shows me (on browser) files like http://domain.com/misc/jquery.js but not those with a dot in its filenames (like http://domain.com/misc/jquery.cookie.js )

casey’s picture

I cannot reproduce on an clean installation.

Do you have cache enabled?
Do you have javascript aggregation enabled?
Do you have extra modules installed? Which?
Are you logged in as an admin user (with all permissions)?

David_Rothstein’s picture

Status: Active » Needs review
FileSize
1021 bytes

The original bug report is easy to reproduce. (@unik's issue seems like a different problem, and I wasn't able to reproduce that one either.)

Here is a patch for the original bug.

This could probably use a test. But on the other hand, the whole overlay module doesn't have any tests, and I'm personally not willing to break that bad pattern right this moment, although it would be a good idea for someone to break it at some point :)

unik’s picture

It seems that I have a different problem after all...
Sorry for confusing anyone with my issue

bdragon’s picture

Subscribing.

Seems to work ok for an issue I was just having with overlay.

Lars Toomre’s picture

Doesn't the drupal_static in the $original_libraries definition need a missing & (ie &drupal_static)?

David_Rothstein’s picture

No, because we want it to be a copy of the data, not a reference.

That way when we copy it back in the last line of code ($libraries = $original_libraries) we are actually putting the original variable back, not something that got modified in the meantime when drupal_render_page() was called.

sun’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs review » Needs work
Issue tags: +Needs backport to D7

I didn't know that Overlay contains wonky code like that.

That said, the patch could use some inline comments that explain the WTF that's happening there.

David_Rothstein’s picture

Status: Needs work » Needs review

There are already some existing inline comments about this (not visible in the patch file, but they appear right above it in the function):

  // Render the region, but do not cache any JavaScript or CSS associated with
  // it. This region might not be included the next time drupal_render_page()
  // is called, and we do not want its JavaScript or CSS to erroneously appear
  // on the final rendered page.

Does that work?

sun’s picture

Status: Needs review » Reviewed & tested by the community

Ah, sorry, yes that works. Also, this is merely a continuation of the existing lines for JS/CSS for libraries, so this is ready to fly.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x and 7.x. Thanks!

aspilicious’s picture

Issue tags: -Needs backport to D7

Removing tags (needs backport to D7 queue cleanup)

Status: Fixed » Closed (fixed)

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

TelFiRE’s picture

Version: 8.x-dev » 7.14
Status: Closed (fixed) » Needs review

Is this supposed to be fixed in 7.14? I'm still getting it.

tim.plunkett’s picture

Version: 7.14 » 7.x-dev
Status: Needs review » Closed (fixed)
Issue tags: +Needs backport to D7

This was committed to D7 here: http://drupalcode.org/project/drupal.git/commit/62b52c8
Fixing tags and version.