PDA

View Full Version : $mainmenu.parent().get(0) is undefined



metaprinter
07-20-2010, 02:55 PM
All Levels Navigational Menu

http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/
EDIT: ignore above, this is the correct link!!!!! -->http://www.dynamicdrive.com/dynamicindex1/ddsmoothmenu.htm

3) Describe problem:
$mainmenu.parent().get(0) is undefined

$mainmenu.parent().get(0).className=setting.classname || "ddsmoothmenu"

found in: ddsmoothmenu.js (line 49)

---everything works, but the above error is being shown in firebug. id like to know why?----

jscheuer1
07-20-2010, 04:00 PM
In the script:

ddlevelsmenu.js

from the demo page you linked to:


All Levels Navigational Menu

http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/

there is no such line. You must be using a similar script or have something confused.

Please post a link to a page on your site that contains the problematic code so we can check it out.

metaprinter
07-20-2010, 05:16 PM
http://www.dynamicdrive.com/dynamicindex1/ddsmoothmenu.htm

I misspoke when i said "everything works" the active class is not being applied to menu items... which i now suspect is because the menu parent is undefined. So how do i define it?

jscheuer1
07-20-2010, 07:29 PM
It's hard to say exactly without seeing your page.

Please post a link to a page on your site that contains the problematic code so we can check it out.

Something like that often means that you have markup that's unexpected by the script. Like an empty menu or an empty sub-menu. Or you are trying to initialize a menu that's not there. Often folks do this by copying the initilaization from the demo and then dropping one of the demo menus, but keeping its initialization.

It may be unrelated to the other problem. You could try making the script ignore the unexpected markup or missing menu:


buildmenu:function($, setting){
var smoothmenu=ddsmoothmenu
var $mainmenu=$("#"+setting.mainmenuid+">ul") //reference main menu UL
if(!$mainmenu || !$mainmenu.parent() || !$mainmenu.parent().get(0)){
return;
}
$mainmenu.parent().get(0).className=setting.classname || "ddsmoothmenu"
var $headers=$mainmenu.find("ul").parent()
$headers.hover(
funct . . .

metaprinter
07-22-2010, 04:15 PM
http://copperheadplumbing.com

right now the error is not showing because i added the above if statement you suggested to ddsmoothmenu.js

still, i'd like to solve the error.

EDIT:
Got the active trail working by using http://docs.jquery.com/Tutorials:Auto-Selecting_Navigation

jscheuer1
07-23-2010, 02:08 AM
About fixing the active trail, Great! The error you were getting was from the second thing I imagined it might be:


Or you are trying to initialize a menu that's not there. Often folks do this by copying the initilaization from the demo and then dropping one of the demo menus, but keeping its initialization.

To fix that, get rid of this:


ddsmoothmenu.init({
mainmenuid: "smoothmenu2", //Menu DIV id
orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu-v', //class added to menu's outer DIV
//customtheme: ["#804000", "#482400"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

You aren't using it. That is, you have no smoothmenu2. So the error you had arose when the script looked for it and couldn't find it.

metaprinter
07-23-2010, 01:04 PM
Thanks again! I was looking at the .js file and the path script... completely forgot about ddsmoothmenu.init scripts.

kressin
04-04-2012, 12:13 PM
I have changed my drupal theme to a commercial one and ever since I get the error

$mainmenu.parent().get(0) is undefined
$mainmenu.parent().get(0).className=setting.classname || “ddsmoothmenu”

according to firebug.

I read the above but I do not have a smoothmenu2 in .init. The error occurs using IMCE with IMCEMUP module, a module to upload multiple files into IMCE. Also the "hack"

if(!$mainmenu || !$mainmenu.parent() || !$mainmenu.parent().get(0)){
return;
}

does not lead to the wanted result. I am a novice with java and js and I would really appreciate advice.

Thank you

jscheuer1
04-04-2012, 05:51 PM
jQuert objects exist even if they're empty. So instead of:



if(!$mainmenu || !$mainmenu.parent() || !$mainmenu.parent().get(0)){
return;
}

try:


if(!$mainmenu.size() || !$mainmenu.parent().size() || !$mainmenu.parent().get(0)){
return;
}

Using .size() after .get(0) won't help though because if it makes it that far, it's an ordinary DOM node and has no .size() function. Most likely, either $mainmenu or $mainmenu.parent() are empty.

kressin
04-05-2012, 03:30 PM
Hi John,

thanks for the reply. Unfortunately

if(!$mainmenu.size() || !$mainmenu.parent().size() || !$mainmenu.parent().get(0)){
return;
}

did not work.

You said

"Most likely, either $mainmenu or $mainmenu.parent() are empty."

Could you be a bit more specific about this please. If they are empty, what do I have to do? I fear I am a complete novice in this field and I would very much appreciate any help you could give.

Thanks!

Roger

jscheuer1
04-05-2012, 06:21 PM
By empty I mean that there are no elements represented by them.

However, at this point the only way to have a chance at resolving this would be to see it. Since it sounds like it may be a CMS problem though, I'm not certain we can resolve it. We'll do our best.

If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.

kressin
04-07-2012, 04:42 PM
Thanks John,

this is the link:

http://urhistory.de/user/247/imce

user: test
Password: test

Site is in german so you have to choose "dateibrowser" then "hochladen" then "durchsuchen".

When choosing an image or multiple images it is not possible to upload them (hochladen).

This is driving me crazy. Site is almost done and ready to be fed with content but since I bought the theme multiple upload no longer is possible.

Thanks for your help!

Happy easter!

Roger

jscheuer1
04-08-2012, 01:54 AM
.

Your page is in violation of Dynamic Drive's usage terms (http://www.dynamicdrive.com/notice.htm), which, among other things, state that the script credit must appear in the source code of the page(s) using the script. Please reinstate the notice first.

That said, after logging in I don't see "dateibrowser" anywhere on the page you linked to or in its source code. However, I am getting the error:


SCRIPT5007: Unable to set value of the property 'className': object is null or undefined
js_NTCTpQmPyTAdreYWt2WQEwlwnZcdOBS8i77CDGqpuKk.js, line 211 character 2

Which does points to:


buildmenu:function($, setting){
var smoothmenu=ddsmoothmenu
var $mainmenu=$("#"+setting.mainmenuid+">ul") //reference main menu UL
$mainmenu.parent().get(0).className=setting.classname || "ddsmoothmenu"
var $headers=$mainmenu.find("ul").parent()
$headers.hover(
function(e){
$(this).children('a:eq(0)').addClass('selected')
},
function(e){
$(this).c . . .

But the fix we talked about isn't there. Maybe you had it there and took it out, and/or did it wrong, or maybe you put it in the wrong file, or maybe it did fix that error but gave rise to a similar error just a little farther along that you confused with the original error, or maybe you didn't clear the cache after making the change, etc. It should go like:


buildmenu:function($, setting){
var smoothmenu=ddsmoothmenu
var $mainmenu=$("#"+setting.mainmenuid+">ul") //reference main menu UL
if(!$mainmenu.size() || !$mainmenu.parent().size() || !$mainmenu.parent().get(0)){
return;
}
$mainmenu.parent().get(0).className=setting.classname || "ddsmoothmenu"
var $headers=$mainmenu.find("ul").parent()
$headers.hover(
function(e){
$(this).children('a:eq(0)').addClass('selected')
},
function(e){
$(this).c . . .

That should either fix it or lead to a different error.

Let me know, and even if there's still a problem, leave it in place so I can see what it did do.

The browser cache may need to be cleared and/or the page refreshed to see changes.

kressin
04-10-2012, 09:32 AM
[QUOTE=jscheuer1;272440].

Your page is in violation of Dynamic Drive's usage terms (http://www.dynamicdrive.com/notice.htm), which, among other things, state that the script credit must appear in the source code of the page(s) using the script. Please reinstate the notice first.

I just checked the source ddsmoothmenu.js file and it contains this credit:

//** Smooth Navigational Menu- By Dynamic Drive DHTML code library: http://www.dynamicdrive.com
//** Script Download/ instructions page: http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/
//** Menu created: Nov 12, 2008

//** Dec 12th, 08" (v1.01): Fixed Shadow issue when multiple LIs within the same UL (level) contain sub menus: http://www.dynamicdrive.com/forums/showthread.php?t=39177&highlight=smooth

//** Feb 11th, 09" (v1.02): The currently active main menu item (LI A) now gets a CSS class of ".selected", including sub menu items.

//** May 1st, 09" (v1.3):
//** 1) Now supports vertical (side bar) menu mode- set "orientation" to 'v'
//** 2) In IE6, shadows are now always disabled

//** July 27th, 09" (v1.31): Fixed bug so shadows can be disabled if desired.
//** Feb 2nd, 10" (v1.4): Adds ability to specify delay before sub menus appear and disappear, respectively. See showhidedelay variable below

//** Dec 17th, 10" (v1.5): Updated menu shadow to use CSS3 box shadows when the browser is FF3.5+, IE9+, Opera9.5+, or Safari3+/Chrome. Only .js file changed.

Not sure if something is missing. If so, please let me know and I will add it.

I am unsure why you could not find the buttons I mentioned in my last post. They are part of the IMCE file browser.

If you could have another look at the site, please log in at

http://urhistory.de

using test/test as username and password (Benutzeranmeldung is the german translation for "login")

In the left sidebar choose the submenu "kontoübersicht" from "Konto+"

You should be able to see "Dateibrowser"

I removed the fix but added it again. I no longer see the error but the problem persists. . When pressing the "hochladen" and then the ""durchsuchen" button and choosing a image from the hard drive and then pressing the "hochladen" button nothing happens.

I will leave the fix in place and perhaps you could have another look at the site.

Thanks a lot

Roger

jscheuer1
04-10-2012, 02:33 PM
There is no "Dateibrowser". I do see File Browser and that part is all in English. If I choose upload and Browse and choose a file, then upload, nothing happens. But that has nothing to do with this menu, at least not that I can see.

About the script credit. Go to the demo page of the script on Dynamic Drive:

http://www.dynamicdrive.com/dynamicindex1/ddsmoothmenu.htm

Look at the code in Step 1 on that page. It shows the credit being used in the on page code:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<link rel="stylesheet" type="text/css" href="ddsmoothmenu.css" />
<link rel="stylesheet" type="text/css" href="ddsmoothmenu-v.css" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="ddsmoothmenu.js">

/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

</script>

<script type="text/javascript">

ddsmoothmenu.init({
mainmenuid: "smoothmenu1", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

ddsmoothmenu.init({
mainmenuid: "smoothmenu2", //Menu DIV id
orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu-v', //class added to menu's outer DIV
//customtheme: ["#804000", "#482400"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

</script>

I don't see anything like that on the page. In fact, I don't see where the menu is being used at all except on that left side bar, which has nothing to do with the file browser.

The menu's javascript is being imported by another script. However, the script credit should still appear on the page if only as an HTML comment:


<!--
/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
-->

And the fix worked. The menu works and there is no error. As for your other problem, that relates to the javascript, Flash, and/or server side code involved. When I hit the Browse button I get a save dialog, I should get an open dialog, or perhaps not as that part of the operation is a Flash object.

In any case, you need to be asking that question in a forum that supports the file browser/file upload feature you're using.

kressin
04-10-2012, 03:42 PM
Thanks John,

I will make sure the credits are added and I will contact the creator of the theme and tell him about the missing credits.

I am kind of sorry the problem does not seem to be related to the ddsmoothmenu script because you have been extremely helpful and competent and I hoped the problem could be solved.

Wish you all the best!

Thanks again

Roger