Close Button at bottom of pull-downs

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
dhyman
Beginner
Beginner
Posts: 5
Joined: Fri Feb 11, 2005 3:23 pm

Close Button at bottom of pull-downs

Post by dhyman »

Is there a simple way that I can add an image to the bottom of a menu that would close the menu when clicked?
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Yes. There are several possibilities. But the approach you take may depend on certain aspects of your menu.

(1) How does the menu get opened? showmenu in an aI(), popup(), or some other method you've devised.

(2) What is the menu's alwaysvisible property set to?

Kevin
dhyman
Beginner
Beginner
Posts: 5
Joined: Fri Feb 11, 2005 3:23 pm

Post by dhyman »

alwaysvisible=1 and opened with an aI()
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

dhyman wrote:alwaysvisible=1 and opened with an aI()
I'm not sure I get that. If the menu you're opening is always visible, then how are you opening it with code in an aI() string? I.e., if the menu is alwasyvisible=1 from the start, then it will be open when the page loads.

Can you post a url to an example page or, if you can't do that, can you post some sample code showing (1) code for the menu that's open (the one you want to close) and (2) code that opened the menu in the first place.

Cheers,

Kevin
dhyman
Beginner
Beginner
Posts: 5
Joined: Fri Feb 11, 2005 3:23 pm

Post by dhyman »

The entire menu is always visible, but the submenus that I want to close with a button are not always visible. Sorry for the confusion.
dhyman
Beginner
Beginner
Posts: 5
Joined: Fri Feb 11, 2005 3:23 pm

Post by dhyman »

Kevin - anything further on this?
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Kevin is out of the country. I'm going to let him continue with this thread. Hang in there a few days.
John
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 dhyman,

Sorry to leave you hanging. As John said, I was out for a while.

I suppose it depends on whether you want to (a) close only the submenu that contains the "close" item that is clicked, or (b) close the entire submenu hierarchy up to and including the one containing the "close" item that is clicked, leaving the main menu open.

I'd write a function to do either. Let's call the function mm_closeClickedMenu().

In the case of (a) above, the menu definition might be:

Code: Select all

function mm_closeClickedMenu()
{
  menuDisplay(_mi[_itemRef][0], 0);
}
You could include the code at the top of your menu_data.js file. This function would close only the menu containing the clicked "close" item.

In the case of (b) above, the function would be:

Code: Select all

function mm_closeClickedMenu()
{
  closeAllMenus();
}
This version would close all currently open submenus, leaving the main menu open.

Both functions are the same function name, but with different innards, depending on what you want to do ("innards" is, of course, a technical term).

The menu item to call the function would look like:

Code: Select all

aI("text=Close;clickfunction=mm_closeClickedMenu();");
or

Code: Select all

aI("text=Close;url=javascript:mm_closeClickedMenu();");
...your preference. Either one should work the same.

Of course, if you want to close all of the submenus, you could just call closeAllMenus() directly, rather than wrapping it up in the mm_closeClickedMenu() function. But the advantages of a function wrapper are (1) you can play with the essential functions (e.g., close one or close all) to see which you like better, and (2) you can add more code to it later if you want to do something else besides close the menus when those particular items are clicked.

Hope that helps,

Kevin
dhyman
Beginner
Beginner
Posts: 5
Joined: Fri Feb 11, 2005 3:23 pm

Post by dhyman »

And suppose I wanted to use an image to active the close action?
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

Hi,
You should be able to use the structure for an image instead of text in the aI string.

Code: Select all

aI("image=whateverimage;clickfunction=mm_closeClickedMenu();");
Ruth
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

As Ruth implied, the mm_closeClickedMenu() function is independent of the type of menu item; it'll work exactly the same whether the menu item is text based or image based.

Cheers,

Kevin
Post Reply