Welcome Guest Search | Active Topics | Sign In | Register

Selecting menu Item with JavaScript Options
Robert
Posted: Tuesday, July 10, 2007 8:21:25 AM
Rank: Member
Groups: Member

Joined: 6/29/2007
Posts: 12
When I used the Menu Clickhandler to select the Menuitem with vb.net code:
e.NavigationItem.Selected = True the menu was selected in the menu.

But when I'm using the Menu Click event (ClientSideOnItemClick) with the eo_Callback JavaScript function the menuitem is not selected anymore. How can I select the menuItem clicked with JavaScript, vb.net or by some configuration for the menu?
eo_support
Posted: Tuesday, July 10, 2007 10:57:59 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi Robert,

You can find a sample at here:

http://www.essentialobjects.com/Demo/Default.aspx?path=Menu\menu_programming\_i2\js_modify_menu

The sample code calls setDisabled, you would need to change it to setSelected.

Thanks
Robert
Posted: Tuesday, July 10, 2007 2:10:47 PM
Rank: Member
Groups: Member

Joined: 6/29/2007
Posts: 12
Thanks for that sample!
I created this code:
Code: JavaScript
var group = info.getItem().getParentGroup();
       for (var i = 0; i < group.getItemCount(); i++)
            group.getItemByIndex(i).setSelected(false);
       info.getItem().setSelected(true);


But i do have some small problems yet with the menu. The sub items are selected even after i select some new main item.
eo_support
Posted: Tuesday, July 10, 2007 2:49:37 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Yes. That is normal because when you select a new item in sub menu A, you won't be clearing out items in sub menu B. The best way for you is to "remember" the last selected item and then unselect that single item:

Code: JavaScript
var g_LastSelectedItem = null;

function menu_item_click_handler(e, info)
{
    if (g_LastSelectedItem)
        g_LastSelectedItem.setSelected(false);

    g_LastSelectedItem = info.getItem();
    g_LastSelectedItem.setSelected(true);
}


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.