Page 1 of 2
active p:menuitem in p:submenu
Posted: 12 Sep 2021, 12:46
by hazemsabbah
hi all,
can anyone till me how theme determine which is the active p:menuitem in p:submenu ??
i try this
<po:menu widgetVar="PoseidonMenuWidget">
<p:submenu label="Requests">
<p:menuitem value="test" outcome="/welcome"/>
<p:menuitem value="test2" outcome="/welcome_1"/>
</p:submenu>
</po:menu>
i get this
thanks ...
Re: active p:menuitem in p:submenu
Posted: 13 Sep 2021, 09:19
by siris
Hi,
Which version of Poseidon are you using?
Best Regards,
Re: active p:menuitem in p:submenu
Posted: 13 Sep 2021, 09:24
by hazemsabbah
poseidon-layout-3.0.0
Re: active p:menuitem in p:submenu
Posted: 13 Sep 2021, 11:44
by siris
By searching the url of the opened page in the menu then if finds the link of that url so determines it accordingly.
Best Regards,
Re: active p:menuitem in p:submenu
Posted: 13 Sep 2021, 15:48
by hazemsabbah
Thank you for replying,
You mean searching the url and what in p:menuitem outcome ??
If yes , Can you please help me to find where i can modify that ?
I need to change it to p:menuitem id not outcome
Thanks
Re: active p:menuitem in p:submenu
Posted: 17 Sep 2021, 10:51
by siris
Hi,
Please take a look at old version of the poseidon templates' layout.js file. I will try to explain about your requested code. You should modify layout.js functions.
Code: Select all
init: function(cfg) {
.
.
.
this.expandedMenuitems = this.expandedMenuitems||[];
},
removeMenuitem: function (id) {
this.expandedMenuitems = $.grep(this.expandedMenuitems, function (value) {
return value !== id;
});
this.saveMenuState();
},
addMenuitem: function (id) {
if ($.inArray(id, this.expandedMenuitems) === -1) {
this.expandedMenuitems.push(id);
}
this.saveMenuState();
},
saveMenuState: function() {
if(this.isHorizontal()) {
return;
}
if(this.wrapper.hasClass('layout-wrapper-static'))
$.cookie('poseidon_menu_static', 'poseidon_menu_static', {path: '/'});
else
$.removeCookie('poseidon_menu_static', {path: '/'});
$.cookie('poseidon_expandeditems', this.expandedMenuitems.join(','), {path: '/'});
},
clearMenuState: function() {
this.expandedMenuitems = [];
$.removeCookie('poseidon_expandeditems', {path: '/'});
$.removeCookie('poseidon_menu_static', {path: '/'});
},
clearActiveItems: function() {
var activeItems = this.jq.find('li.active-menuitem'),
subContainers = activeItems.children('ul');
activeItems.removeClass('active-menuitem');
if(subContainers && subContainers.length) {
subContainers.hide();
}
},
clearLayoutState: function() {
this.clearMenuState();
this.clearActiveItems();
},
restoreMenuState: function() {
var menuCookie = $.cookie('poseidon_expandeditems');
if (menuCookie) {
this.expandedMenuitems = menuCookie.split(',');
for (var i = 0; i < this.expandedMenuitems.length; i++) {
var id = this.expandedMenuitems[i];
if (id) {
var menuitem = $("#" + this.expandedMenuitems[i].replace(/:/g, "\\:"));
menuitem.addClass('active-menuitem');
var submenu = menuitem.children('ul');
if(submenu.length) {
submenu.show();
}
}
}
}
.
.
.
},
Best Regards,
Re: active p:menuitem in p:submenu
Posted: 15 Jan 2022, 22:43
by jreyes256
Greetings.
I'm using version 4.1 of Poseidon Layout and I have the same problem. I have a menu and when I place the outcome the links appear as active.
Re: active p:menuitem in p:submenu
Posted: 21 Jan 2022, 09:31
by mert.sincan
Hi,
Is your problem solved with the above code blocks?
Best Regards,
Re: active p:menuitem in p:submenu
Posted: 08 May 2022, 06:44
by jreyes256
mert.sincan wrote: ↑21 Jan 2022, 09:31
Hi,
Is your problem solved with the above code blocks?
Best Regards,
Hi, I tell you that the problem persists, I did not understand the above, I copy the code in the layout.js?
Re: active p:menuitem in p:submenu
Posted: 09 May 2022, 00:12
by jreyes256
<po:menu widgetVar="PoseidonMenuWidget">
<p:submenu id="om_components" label="#{bundle.label_menu}" icon="pi pi-star-fill">
<p:menuitem id="om_dashboard" value="#{bundle.label_dashboard}" icon="pi pi-home" outcome="#{bundle.ruta_url_dashboard}"/>
<p:menuitem id="om_useradmin" value="#{bundle.label_gestion_usuario}" icon="pi pi-users" rendered="#{appMenu.menuBarAdministracion}" outcome="#{bundle.ruta_url_gestion_usuario}"/>
<p:submenu id="om_balances" label="#{bundle.label_balance}" rendered="#{appMenu.menuBarAdministracion}" icon="pi pi-chart-line">
<p:menuitem id="om_bl_libro_inventario" value="#{bundle.label_balance_libro_inventario}" rendered="#{appMenu.menuBarAdministracion}" icon="pi pi-cog" outcome="#{bundle.ruta_url_libro_inventario}" />
</p:submenu>
......
They appear active to me, because this happens if I have the pro and extended version.