|
Rank: Newbie Groups: Member
Joined: 3/25/2009 Posts: 5
|
I have set up my menu to work like a tabbed system with menus using the TargetFrame feature.
When a page opens in the targetFrame what JS can I include in that page to set the selected tab in the navigation Frame?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, You would need to call this function to set a menu item's selected state: http://doc.essentialobjects.com/library/1/jsdoc.public.navigationitem.setselected.aspxIn order to call this function, you will need to get the corresponding menu item object first. That would require you to know how to use our client side JavaScript interface: http://doc.essentialobjects.com/library/1/clientapi_howto.aspxNote that the menu allows multiple selected items. So setting one item to selected does not automatically clears previous selected item. Thus you will need to use a global variable to "remember" the previous selected item and clear its selected state when a new item is selected. Cross frame is largely irrelevant as to setting selected item. The only issue is if you want to call code that is inside another frame, you will need to get that frame object first. This part is not in anyway related to the menu. Hope this helps. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/25/2009 Posts: 5
|
I am running the following on item click
function SelectRoot(evnt, sender) { var item = sender.getItem(); var parent = item; while (parent.getLevel() != 0) { parent = parent.getParentItem(); } parent.setSelected(true); }
This works only when I select an item form a submenu and even though it will select the top item when selecting an item from a sub menu. If I mouseover the top level items it will trigger the on hover and then return back to the unselected state.
However when setting selected on a top level item on the server it always is selected and is not affected by the mousehover.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
I do not believe hover clears selected state. Hover and Selected are two different flags that can be set/cleared indepdently. So once you set the parent item as Selected, it should stay Selected until you clears it or the page reloads.
If the problem continues, please create a test page that we can use to reproduce the problem. We will be happy to take a look as soon as we have that.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/25/2009 Posts: 5
|
I have created a sample app... How do I attach to post?
What I would like to see happen is that after a tab get selected. You can hover over the newly selected tab with the mouse and not have it reset. (like how it works whne you set form the server side)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
We have replied your private message. Please click "Inbox" on the top of the forum to view the message.
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, We have looked into your test code and it appears to be an issue. The issue occurs because the sub menu is recreated everytime a new page is loaded inside the target frame (because the sub menu is being created inside the target frame). This also reset the parent item's selected state. We have developed a workaround for this issue: 1. Add the following JavaScript function "SelectItem" into the header section of your Default.aspx, and also an onload handler to your "body" frame inside your Default.aspx to call this function:
Code: JavaScript
function SelectItem()
{
//This function is being called everytime a new page is loaded into
//the "body" frame.
var frame = frames["header"];
if (frame.SelectItem)
frame.SelectItem();
}
Code: HTML/ASPX
<frame src="body.aspx" name="body" onload="SelectItem()" ....></frame>
2. Change the JavaScript code inside your header.aspx as follow:
Code: JavaScript
var g_lastItem = null;
function SelectRoot(evnt, sender)
{
//We no longer select the item when the menu item is clicked.
//Instead we remember the item and wait for the target frame
//to finish loading, at which point SelectItem is called
g_lastItem = sender.getItem();
}
function SelectItem()
{
//This function is similar to the original SelectRoot function,
//except for that it is called when the new page finishes
//loading instead of when the menu item is clicked
var parent = g_lastItem;
if (!g_lastItem)
return;
while (parent.getLevel() != 0)
{
parent = parent.getParentItem();
}
//This is needed to "remind" the menu that it should "get
//ready". Otherwise certain internal data are not initialied
//until you move mouse over the menu
parent.setDisabled(true);
parent.setDisabled(false);
//Now select the menu item
parent.setSelected(true);
alert('selected');
}
This should get you going. Please let us know whether it works for you or not. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/25/2009 Posts: 5
|
In IE8 I get a bunch of errors (Access Denied) when browsing with tabs. and hovering menus.
Is this already reported and being worked on?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
A similar issue related to cross frame menu has been reported to us and we have an internal build that already fixed it. So you may want to take a look of that build. We will PM you with the download location.
Please confirm whether the workaround code we provided works for you or not so that we can decide whether to close that issue.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/25/2009 Posts: 5
|
I am still having some issues with IE8. If you set a variable in the frame with the navigation say "Anonymous" = true
And then in the main body frame you have someone login and then on load of an authenticated body page check the navigation's anonymous variable and if true force the navigation menu frame to refresh (in order to have menu items available to an authenticated user loaded) then I will get permission denied errors sometimes.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Would you be able to provide a (or a set of) test page? We can then try to run the page and see if we can reproduce the problem here.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
We have posted a new build (2009.0.16) that should fix this problem. You can download the new build from our download page.
Thanks!
|
|