|
Rank: Newbie Groups: Member
Joined: 4/1/2009 Posts: 5
|
Hi, i have a Menu which should has following behaviour: It should keep expanded since i click on an item which has no subgroup. After i've clicked on this item, the active Subgroup should collapse. I've seen the option "KeepExpandedOnClick". Unfortunately this option keeps the Subgroup open till i click on another item on my page. My first step was to create a javascript function for "ClientSideOnItemClick".
Code: JavaScript
function OnItemClick(e, info) {
var item = info.getItem();
if (item.getSubGroup() == null) {
eo_Callback("cbPanel", info.getItem().getText());
}
}
Is there a possibility to get my menu working as needed? Thanks, best regards, Richard
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Richard wrote:It should keep expanded since i click on an item which has no subgroup. After i've clicked on this item, the active Subgroup should collapse. I've seen the option "KeepExpandedOnClick". Unfortunately this option keeps the Subgroup open till i click on another item on my page.
I am not sure whether I got your question correctly. KeepExpandedOnClick should "keep expanded since click on an item which has no subgroup". But I do not know what you mean by "After I've clicked on this item, the active Subgroup should collapse". This seems to contradict your first sentence. Do you mind to explain it in detail? Richard wrote: My first step was to create a javascript function for "ClientSideOnItemClick".
function OnItemClick(e, info) { var item = info.getItem(); if (item.getSubGroup() == null) { eo_Callback("cbPanel", info.getItem().getText()); } }
This does not appear to have anything with sub menu expanding though. One problem in your code is that you can not use item.getSubGroup() to check whether the menu item has sub menu. A menu item can have sub menu settings but not sub menu items. In that case getSubGroup will return a valid NavigationItemGroup object but if you call the NavigationItemGroup object's getItemCount method, it will return 0. So you need to check both. Hope this helps. Please reply with more information and we will look into it again. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 4/1/2009 Posts: 5
|
i'll try to explain it in more detail :-)
My Main Menu-> Test1 | Test2(this Menu has also Sub entries)
My Sub Menu of Test1 -> SubT1 | SubT2
My SubMenu of Sub Menu SubT1 -> SubSubT1
If I click on Test1 or SubT1 the Menu should stay Expanded. Nothing should happen If I click SubSubT1 -> All Subgroups should be closed and the function "ClientSideOnItemClick" should be called.
menuitems which have subitems -> keep menu expanded menuitems without subitems -> call function ClientSideOnItemClick and collape Menu
Thanks for the tip with getItemCount method.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, You will need to: 1. Set the menu's KeepExpandedOnClick to true; 2. Optionally, set the menu's CollapseDelay to 0. This is often used when you have KeepExpandedOnClick set to true. Otherwise the menu will stay expanded when you click on an item, but will close when you move your mouse alway from the menu; 3. Change your ClientSideOnItemClick handler to:
Code: JavaScript
function OnItemClick(e, info)
{
var item = info.getItem();
//Close the sub menu if we have no child items
if (!item.getSubGroup() || !item.getSubGroup().getItemCount())
{
//Find the top level item that contains
//the item being clicked
while (item.getLevel() > 0)
item = item.getParentItem();
//Collapse the top item
item.collapseSubMenu();
}
}
This should get you going. Please let us know if it works for you. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 4/1/2009 Posts: 5
|
Thanks for your help. Problem solved.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Great. Thanks for the update!
|
|