Hi all,
can I set a menu item in the omega menu "active" (and all others as not active) manually (by code) without actually clicking the menu item.
My use case is that - after login - I see the home page, but the menu link for the home page is not active. So I want to activate this manually (e. g. by some javascript code) when i am on the home page.
BTW: You have the same issue on the Omega demo page, where the "Dashboard" link is not activated right after initially visiting the page, although you see the "Dashboard" page.
Thanks in advance!
Manually activate omega menu item
Forum rules
Please note that response time for technical support is within 3-5 business days.
Please note that response time for technical support is within 3-5 business days.
-
- Posts: 5281
- Joined: 29 Jun 2013, 12:38
You can add the id of active menuitem to cookie after clicking login button;
Exp;
login.xhtml
sidebar.xhtml
Exp;
login.xhtml
Code: Select all
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
...
<script type="text/javascript">
function addOmegaCookie() {
$.cookie('omega_expandeditems', 'om_dashboard', {path: '/'}); /* 'om_dashboard' is the id of a menuitem in the po:menu */
}
</script>
</h:head>
<h:body styleClass="login-body">
...
<div class="ui-g-12">
<p:button outcome="dashboard" value="Login" icon="fa fa-check" onclick="addOmegaCookie()" />
</div>
...
</h:body>
</html>
Code: Select all
<div class="menu">
<po:menu>
<p:menuitem id="om_dashboard" value="Dashboard" icon="fa fa-home" outcome="/dashboard"/>
...
Github Profile: https://github.com/mertsincan
-
- Information
-
Who is online
Users browsing this forum: No registered users and 17 guests