Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: $mainmenu.parent().get(0) is undefined

  1. #1
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default $mainmenu.parent().get(0) is undefined

    All Levels Navigational Menu

    http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/
    EDIT: ignore above, this is the correct link!!!!! -->http://www.dynamicdrive.com/dynamici...smoothmenu.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?----
    Last edited by metaprinter; 07-20-2010 at 05:17 PM. Reason: corrected link

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    In the script:

    ddlevelsmenu.js

    from the demo page you linked to:

    Quote Originally Posted by metaprinter View Post
    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default here is the correct link

    http://www.dynamicdrive.com/dynamici...smoothmenu.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?
    Last edited by metaprinter; 07-20-2010 at 05:25 PM.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    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 . . .
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default here is the link to the site

    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:Aut...ing_Navigation
    Last edited by metaprinter; 07-22-2010 at 06:41 PM. Reason: Got the active trail working

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Jul 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Thanks again.

    Thanks again! I was looking at the .js file and the path script... completely forgot about ddsmoothmenu.init scripts.

  8. #8
    Join Date
    Apr 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Undefined Error with drupal theme

    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

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    jQuert objects exist even if they're empty. So instead of:

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

    Code:
    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  10. #10
    Join Date
    Apr 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •