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:14

Error if a menu is empty


Poster: bmaras
Dated: Friday September 5 2003 - 16:57:54 BST

First of all, my congratulations to the developers of this menu, it is a wonderful tool that I will probably use in my future sites

Anyway, I have a javascript error ("_M has no properties") if one of the menus has no items in it.

Example :

with(milonic=new menuname("taxe")){
itemwidth=200;
borderwidth=1;
style=styleMenus;
alignment="left";

}

It does not happen if there is at least one item in the menu (i.e. one call to aI(...) )


Poster: Maz
Dated: Friday September 5 2003 - 17:33:27 BST

you can use one line like this:

Code:
aI("text= ;");


I also use type=header; to make it match menu color.

regards
maz


Poster: Hergio
Dated: Friday September 5 2003 - 18:06:23 BST

Thats a known scenario and its by design. You are not allowed to have menus with menu items in them. It makes sense, why have a menu without anything in it?


Poster: bmaras
Dated: Monday September 8 2003 - 10:30:01 BST

In fact, I'd like to implement user rights on the menu.
Each menu item can be disabled if the user doesn't have the right to use it :
<% if user_has_the_rights() {%>
aI(...)
<% } %>
Thus, it can happen that a user has no rights for any item of a menu.

The workaround could be to make one more test to hide the menu if all its items are disabled

Anyway, I planned to use the "type=disabled" option to disable the menu items. But it is not visual enough (I would have liked a greyed line for example). If there is a way to do it, that would be great

Thanks for your replies


Poster: Hergio
Dated: Monday September 8 2003 - 13:11:53 BST

I see your case. The menu doesn't inheritly support such ability when disabling an item, but since you are doing your menus based on user permissions, you can manually set the colors to a color close to the background color so it definetly looks disabled..try this...
Code:
if( user_has_permission )
{
   secToken = "showmenu=secureMenu;";
}else{
   secToken = "type=disabled;oncolor=#aaaaaa;offcolor=#aaaaaa;";
}

...
aI("text=High Security Stuff;url=#;" + secToken);
...


Poster: bmaras
Dated: Monday September 8 2003 - 14:30:58 BST

Thanks a lot,
that's a good idea. I'll try it


Poster: John
Dated: Monday September 8 2003 - 15:26:16 BST

Another option is to use Dave's code, and if the user has no rights build an aI("text=You are not allowed to use this menu;url=#;type=header;");, or something along those lines.