Hello,
is there a way to set the current active Menu Item in Code.
I do navigation via navigation-rules and would like to adjust the selected Menu Item based on the current page.
I tried this approach: http://blog.awolski.com/keeping-a-prime ... em-active/
but since the Menu-Component in Poseidon is a special component included in the theme, this approach did not work out for me.
I would be thankful for any suggestions on how i can set the active menu item of the PoseidonMenu-Component via code.
Kind regards,
Poseidon Set active 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
We use jquery cookie for stateful feature on Poseidon menu. I think you can use it. You need to add id of active menu item into cookie. Exp;
Code: Select all
<script type="text/javascript">
function testFunc() {
var $this = PF('me');
if($this) {
/* clear state */
$this.expandedMenuitems = [];
$this.deactivateItems($this.menu.find('li.active-menuitem'));
$this.addMenuitem('menuform:om_doc');
$this.restoreMenuState();
}
}
</script>
//menu.xHtML
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:pp="http://primefaces.org/poseidon">
<h:form id="menuform">
...
<pp:menu widgetVar="me">
...
<p:menuitem id="om_doc" value="Documentation" icon="fa fa-fw fa-book" outcome="/docs"/>
</pp:menu>
...
</h:form>
</ui:composition>
Code: Select all
//forms.xhtml
<p:commandButton value="Docs" action="docs.xhtml" oncomplete="testFunc();"/>
Github Profile: https://github.com/mertsincan
-
- Information
-
Who is online
Users browsing this forum: No registered users and 6 guests