After upgrading to the latest version of Addresses (6.x-1.12), we noticed an odd phenomenon when using Internet Explorer (specifically: IE7, IE8 & IE9 on Windows XP and Windows 7). When attempting to add or edit a node that includes an "Addresses - CCK" field, we discovered that the collapsed fieldsets on the page didn't work. Common fieldsets like "Menu settings," "Input format," and "Publishing options" were no longer expandable — clicking on the fieldset label yielded no results. All the fieldsets on the page looked and acted like plain, flat text. NOTE: This phenomenon only occurs when a content type includes an "Addresses - CCK" field. All the rest of our content types behave normally. Previous versions of Addresses didn't have this problem.
Using IE9's developer tools (F12), I discovered that a JSON error was being produced:
SCRIPT5009: 'JSON' is undefined
addresses.js?V, line 33 character 5Looking at addresses.js and comparing it to the same file in the previous version of Addresses, I saw that the line "'attributes':JSON.stringify(attributes)" was added. Removing that line solved the fieldset problem — the fieldsets became clickable again, expanding and collapsing as they should.
However, I figure removing that line isn't an option, especially since this problem seems isolated to Internet Explorer.
At the top of addresses.js, I added the following code:
if (!JSON) JSON = {};
This ensures that JSON has a value, even if the browser hasn't declared it for some reason. Adding that line *does* solve the problem in IE (fieldsets become expandable again), although an error is still produced:
SCRIPT5009: 'JSON' is undefined
addresses.js?V, line 9 character 1Can you think of a better, more official way to resolve this problem — one that can be added to the module in the future?
Thanks!
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | fixes_JSON_in_Addresses_breaks_Drupal_fieldsets_in_IE-1312492.patch | 1.71 KB | dkinzer |
Comments
Comment #1
wildlife commentedI'm having the same error and problem. Any solution would be appreciated.
Comment #2
AlexisWilke commentedThe add came from this issue:
#1216746: Addresses province field does not maintain attributes after ajax call.
Thank you.
Alexis Wilke
Comment #3
dkinzer commentedUnfortunately some browsers (IE, not sure if all versions) do not natively include the JSON library (object). The easiest solution is to check that JSON exists before using it.
If not, then no harm is done. The functionality reverts to how it used to behave. That's what the patch below will do.
The more ambitious approach would be to then define a JSON parser to stringify the object. Fortunately the JSON library is open source:
https://github.com/douglascrockford/JSON-js
We could include it with Addresses. But I think I'll leave it to someone else to decide whether it's worth doing so.
Comment #4
AlexisWilke commentedOkay, I put the patch in.
slanger, let us know whether that works for you.
Thank you.
Alexis
See: http://drupalcode.org/project/addresses.git/commit/ffac965
Comment #6
slanger commentedThe patch works great -- thank you! I appreciate you looking into this so quickly.
Comment #6.0
slanger commentedCorrected a typo