Javascript error causing problems with other modules

easp - August 7, 2009 - 16:10
Project:SimpleMenu
Version:6.x-1.2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community
Description

Firefox is throwing a javascript error: "simplemenu is not defined" with a reference to the following line.

var menu = $(simplemenu).attr("id", "simplemenu").addClass('clear-block');

The javascript error is creating problems with the IMCE module. I could not find a patch for this bug. Has anyone else experienced this problem?

#1

easp - August 7, 2009 - 16:18

The same problem exists with the dev version.

#2

jancor - August 9, 2009 - 14:30

Hi, in file simplemenu.js try add
+ if (typeof(simplemenu) != "undefined") {
var menu = $(simplemenu).attr("id", "simplemenu").addClass('clear-block');
+ }

#3

easp - August 10, 2009 - 13:44

I tried the fix above. I receive a different javascript error now which still breaks my module. Error is:

Error: [Exception... "Node cannot be inserted at the specified point in the hierarchy" code: "3" nsresult: "0x80530003 (NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)" location: "http://wwwdev.nebrwesleyan.edu/misc/jquery.js?7 Line: 13"]

It appears the fix broke something in jquery.js

Here is the patch I added to simplemenu.js

if (typeof(simplemenu) != "undefined") {
var menu = $(simplemenu).attr("id", "simplemenu").addClass('clear-block');
}

#4

jrust - September 18, 2009 - 20:47

I was having this problem because I had defined some pages not to show the simplemenu under simplemenu's advanced settings.

On those pages where it was not supposed to be showing it was throwing the $(simplemenu) not defined error. Putting this at line 11 fixed it for me:
if (typeof(simplemenu) == "undefined") {
return;
}

#5

davidwhthomas - September 28, 2009 - 03:27

I too had this error.

I debugged and found the problem is that simplemenu_init is adding all the javascript on pages where simplemenu is not actually enabled. Because there is no target html element, the js error is thrown.

The attached patch fixes this by checking simplemenu_enabled() before adding the javascript in simplemenu_init

DT

AttachmentSize
simplemenu.module.patch 566 bytes

#6

davidwhthomas - September 28, 2009 - 03:28
Status:active» needs review

#7

Jay Matwichuk - September 29, 2009 - 17:45

That patch solved the problem for me. Thanks mate.

#8

davidwhthomas - October 2, 2009 - 23:29
Status:needs review» reviewed & tested by the community

Perhaps the patch in #5 could be committed to cvs?

#9

orizu - December 7, 2009 - 15:46

Having traced the issues with IMCE to simplemenu_init, this worked for me and is now in play across 3 of my sites. +1 for commit

 
 

Drupal is a registered trademark of Dries Buytaert.