active p:menuitem in p:submenu

Forum rules
Please note that response time for technical support is within 3-5 business days.
hazemsabbah
Posts: 5
Joined: 06 May 2018, 08:54

12 Sep 2021, 12:46

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

Image

thanks ...

siris
Posts: 322
Joined: 29 Jul 2019, 13:57

13 Sep 2021, 09:19

Hi,

Which version of Poseidon are you using?

Best Regards,

hazemsabbah
Posts: 5
Joined: 06 May 2018, 08:54

13 Sep 2021, 09:24

poseidon-layout-3.0.0

siris
Posts: 322
Joined: 29 Jul 2019, 13:57

13 Sep 2021, 11:44

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,

hazemsabbah
Posts: 5
Joined: 06 May 2018, 08:54

13 Sep 2021, 15:48

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

siris
Posts: 322
Joined: 29 Jul 2019, 13:57

17 Sep 2021, 10:51

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,

jreyes256
Posts: 4
Joined: 09 Mar 2015, 18:15

15 Jan 2022, 22:43

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.

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

21 Jan 2022, 09:31

Hi,

Is your problem solved with the above code blocks?

Best Regards,

jreyes256
Posts: 4
Joined: 09 Mar 2015, 18:15

08 May 2022, 06:44

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?

jreyes256
Posts: 4
Joined: 09 Mar 2015, 18:15

09 May 2022, 00:12

Image
<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.

Post Reply

Return to “Poseidon - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests