active p:menuitem in p:submenu

Post Reply
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,

Post Reply

Return to “Poseidon - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests