Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:54

Close Button at bottom of pull-downs


Poster: dhyman
Dated: Friday February 11 2005 - 14:28:46 GMT

Is there a simple way that I can add an image to the bottom of a menu that would close the menu when clicked?


Poster: kevin3442
Dated: Friday February 11 2005 - 20:11:04 GMT

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


Poster: dhyman
Dated: Friday February 11 2005 - 20:32:07 GMT

alwaysvisible=1 and opened with an aI()


Poster: kevin3442
Dated: Friday February 11 2005 - 23:57:28 GMT

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


Poster: dhyman
Dated: Monday February 14 2005 - 11:58:16 GMT

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.


Poster: dhyman
Dated: Wednesday February 16 2005 - 14:10:33 GMT

Kevin - anything further on this?


Poster: John
Dated: Wednesday February 16 2005 - 16:56:28 GMT

Kevin is out of the country. I'm going to let him continue with this thread. Hang in there a few days.


Poster: kevin3442
Dated: Tuesday February 22 2005 - 1:08:06 GMT

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:
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:
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:
aI("text=Close;clickfunction=mm_closeClickedMenu();");

or
Code:
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


Poster: dhyman
Dated: Wednesday March 9 2005 - 15:53:19 GMT

And suppose I wanted to use an image to active the close action?


Poster: Ruth
Dated: Wednesday March 9 2005 - 16:26:37 GMT

Hi,
You should be able to use the structure for an image instead of text in the aI string.
Code:
aI("image=whateverimage;clickfunction=mm_closeClickedMenu();");


Ruth


Poster: kevin3442
Dated: Wednesday March 9 2005 - 21:57:40 GMT

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