Error if a menu is empty

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
bmaras
Beginner
Beginner
Posts: 3
Joined: Fri Sep 05, 2003 4:36 pm

Error if a menu is empty

Post by bmaras »

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(...) )
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

you can use one line like this:

Code: Select all

aI("text= ;");
I also use type=header; to make it match menu color.

regards
maz
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

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?
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
bmaras
Beginner
Beginner
Posts: 3
Joined: Fri Sep 05, 2003 4:36 pm

Post by bmaras »

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
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

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: Select all

if( user_has_permission )
{
   secToken = "showmenu=secureMenu;";
}else{
   secToken = "type=disabled;oncolor=#aaaaaa;offcolor=#aaaaaa;";
} 

...
aI("text=High Security Stuff;url=#;" + secToken);
...
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
bmaras
Beginner
Beginner
Posts: 3
Joined: Fri Sep 05, 2003 4:36 pm

Post by bmaras »

Thanks a lot,
that's a good idea. I'll try it
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

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.
John
Post Reply