How does closeAllMenu() work?

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
Jukka
Beginner
Beginner
Posts: 1
Joined: Fri Sep 15, 2006 10:04 am

How does closeAllMenu() work?

Post by Jukka »

I have about 20 menus in one jsp-page, but only few of them are visible at a time. Depending on a situation different menus should be displayed.

http://milonic.com/menu_methods.php says:

"menuDisplay displays a menu. You need to have a reference to a menu or other HTML object and show/hide is boolean value:
Syntax is menuDisplay(gmobj("menuname"),1) to show and menuDisplay(gmobj("menuname"),0) to hide."

"closeAllMenus will hide ALL menus, even if they are visible but moved out of view. This command is used to clear the screen of unwanted menus."


I made a test:
menu_data.js

Code: Select all

...
with(milonic=new menuname("menuname"))
{
    position="relative"; alwaysvisible=0; orientation="horizontal"; style=menuStyle;
    aI("text=menuitem0;url=#;");
    aI("text=menuitem1;url=#;");
    aI("text=menuitem2;url=#;");
}
drawMenus();
testmenu.html

Code: Select all

...
<a href="#" onclick="javascript:menuDisplay(gmobj("menuname"),1)">Close all menus</a>
<a href="#" onclick="javascript:closeAllMenus();">Close all menus</a>
...
...but the menu only stays hidden.
If I change the property alwaysvisible to 1, I can't hide the menu with the method closeAllMenus(),
and if it is null or 0 the menu is hidden and I can't get it visible with method menuDisplay.

What should I do?
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi Jukka,

You have a couple of syntax issues in your sample code. For example, the double quotes around "menuname" here:

Code: Select all

<a href="#" onclick="javascript:menuDisplay(gmobj("menuname"),1)">Close all menus</a> 
will will cause a parsing error for the onclick attribute (i.e., onclick="..."). Single quotes would be better.

Also, you don't need to follow onclick with "javascript". I.e.,

Code: Select all

onclick="closeAllMenus()"
will work.

closeAllMenus() will close all open menus that are not set to alwaysvisible=1; i.e., alwaysvisible takes precedence.

Some have found the menuDisplay() function a little tricky. An easier one is popup(). You might five that a try. Try this:

Code: Select all

<a href="#" onclick="popup('menuname', 1)">Open 'menuname'</a>
<a href="#" onclick="closeAllMenus();">Close all menus</a>
If you need to use menuDisplay() for something that popup() and closeAllMenus() can't handle, give a holler and we'll work it out.

Hope that helps,

Kevin
Post Reply