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
The same problem exists with the dev version.
#2
Hi, in file simplemenu.js try add
+ if (typeof(simplemenu) != "undefined") {
var menu = $(simplemenu).attr("id", "simplemenu").addClass('clear-block');
+ }
#3
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
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
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
#6
#7
That patch solved the problem for me. Thanks mate.
#8
Perhaps the patch in #5 could be committed to cvs?
#9
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