Welcome Guest Search | Active Topics | Sign In | Register

Menu: ItemClick doesn't fire? Options
Saed
Posted: Saturday, March 7, 2009 7:11:49 AM
Rank: Advanced Member
Groups: Member

Joined: 10/15/2008
Posts: 45
Hi there,
I'm trying to utilise ItemClick to set Selected property of Menu Items. As advised in documentation, I enabled RaisesServerEvent for the Menu, but without luck.

Menu is contained in a UserControl, which feeds into Application's Index page. Index page has an iFrame where pages load. Consequently, TargetWindow property of Menu Items is set to said iFrame name/ID. Everything is OK except for ItemClick.

Here is Menu declaration:

Code: HTML/ASPX
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="globalMenu.ascx.vb" Inherits="TimeApp.globalMenu" %>
<%@ Register TagPrefix="eo" Namespace="EO.Web" Assembly="EO.Web" %>

<div id="menuBar">
    <div id="mainMenu">
        <eo:Menu 
            id="globalNav"
            runat="server"
            width="550px"
            RightToLeft="<%$ Resources:General, loc_Prop_RightToLeft %>" 
            RaisesServerEvent="true"
            EnableKeyboardNavigation="True"
            ImageBaseDirectory="~/images/nav/Menu/">
            <TopGroup Style-CssClass="TopLevel"></TopGroup>
            <LookItems>
            ...
            </LookItems>
        </eo:Menu>
    </div>
    ...
</div>



And the Handler:

Code: Visual Basic.NET
Protected Sub GetClicked(ByVal sender As Object, ByVal e As EO.Web.NavigationItemEventArgs) Handles globalNav.ItemClick

     MsgBox("I am fired...")

End Sub



Am I missing something here?

Regards,


Saed Hamdan
"Man may be destroyed but not defeated" -Hemmingway
eo_support
Posted: Saturday, March 7, 2009 10:37:57 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Check whether you have NavigateUrl set. You won't be able to have post back and NavigateUrl at the same time. Post back comes back to the same Url, while NavigateUrl goes to a different Url.

Thanks
Saed
Posted: Saturday, March 7, 2009 2:01:00 PM
Rank: Advanced Member
Groups: Member

Joined: 10/15/2008
Posts: 45
eo_support wrote:
Check whether you have NavigateUrl set. You won't be able to have post back and NavigateUrl at the same time. Post back comes back to the same Url, while NavigateUrl goes to a different Url.

Already set, and all pages load into iFrame without problems.


Anyway, I'm trying working that out via JS, and it sounds working.

Code: JavaScript
function getClicked(e, eventInfo)
{
   var isClicked = eventInfo.getItem();     
   handleSelected(isClicked, true);
}
      
function handleSelected(thisItem, status)
{
   var levels = thisItem.getLevel();
   switch (levels)
   {
      case 1:
         thisItem.setSelected(status);
         thisItem.getParentItem().setSelected(status);
      case 2:
         thisItem.setSelected(status);
         thisItem.getParentItem().setSelected(status);
         thisItem.getParentItem().getParentItem().setSelected(status);
   }    
}


However, set MenuItems remain selected when clicking other MenuItems. Therefore, I intend to utilise same handleSelected() function to de-select them, since that little smart trick in documentation didn't work:

Code: JavaScript
eventInfo.getItem().setSelected(!eventInfo.getItem().setSelected());


In VB, I would handle that as:

Code: Visual Basic.NET
Dim itemPath As String = "1/2/3"
Dim thisItem As EO.Web.MenuItem = CType(myMenu.FindItem(itemPath), EO.Web.MenuItem)
...


How could I achieve that in JS, especially CType()? Tried the following but got errors:

Code: JavaScript
function clearSelected(passedPath)
{
   var mainMenu = document.getElementById('<%= myMenu.ClientID %>');
   var wasClicked = mainMenu.findItem(passedPath);
   handleSelected(wasClicked, false);
}


Many Thanks in advance.

Regards,


Saed Hamdan
"Man may be destroyed but not defeated" -Hemmingway
Saed
Posted: Monday, March 9, 2009 10:19:07 PM
Rank: Advanced Member
Groups: Member

Joined: 10/15/2008
Posts: 45
Well, any assistant on this?

Thanks.

Regards,

Saed Hamdan
"Man may be destroyed but not defeated" -Hemmingway
eo_support
Posted: Monday, March 9, 2009 10:40:01 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
You didn't understand our original reply correctly. We have already pointed out that you can not use NavigateUrl and RaisesServerEvent at the same time and ask you to check NavigateUrl. You replied you do have NavigateUrl set --- that is precisely why RaisesServerEvent is not working for you.
Saed
Posted: Tuesday, March 10, 2009 6:34:53 AM
Rank: Advanced Member
Groups: Member

Joined: 10/15/2008
Posts: 45
Guess you are right. I thought you meant the opposited'oh!

OK, what about my ClientSide approach? Could you assist in achieving what I'm up to?

Thanks.

Regards,

Saed Hamdan
"Man may be destroyed but not defeated" -Hemmingway
eo_support
Posted: Tuesday, March 10, 2009 9:32:58 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
You should use eo_GetObject instead of document.getElementById to get our client side menu object.


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.