Navigation menu, wrong highlighted menuitem

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
sefatascan
Posts: 3
Joined: 10 Sep 2020, 09:16

10 Sep 2020, 10:03

Hello,
I am using Avalon Theme. For navigation menu was used <pm:menu model = #{ ... }/> element.
Model elements returns {DefaultMenuItem, DefaultSubMenu, DefaultSubMenu ....}
Menu is rendering properly. But sometimes, when I was click a menu item, It highlighted wrong the current selected.

For exeample, I clicked 2.submenu>1.menuitem, it highlighted 4.submenu>3.menuitem.
But current url is 2.submenu>1.menuitem url
#{managedBean.panelMenuModel} = https://ibb.co/59R7BnN

And I shared you a gif https://ibb.co/PT69Lp2. The problem is exactly as you can see.
How can I fix that?

Code: Select all

<pm:menu  model="#{managedBean.panelMenuModel}"  />
Info : Primefaces 6.1 , Mojarra 2.2.11, Avalon 2.1.2 and SpringBoot

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

12 Sep 2020, 14:38

But sometimes, when I was click a menu item, It highlighted wrong the current selected.
- Are you updating pm:menu after clicking this menuitem? Also, could you please check the id of menuitems? They have to be unique.

Please see this code in layout.js;

Code: Select all

   restoreMenuState: function() {
        var menucookie = $.cookie('avalon_expandeditems');
        if (menucookie && !this.isSlim() && !this.wrapper.hasClass('menu-layout-horizontal')) {
            this.clearActiveItems();
            
            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();
                    }
                }
            }
        }
        
        var inlineProfileCookie = $.cookie('avalon_inlineprofile_expanded');
        if (inlineProfileCookie) {
            this.profileMenu.show().prev('.profile').addClass('profile-expanded');
        }
    },
Maybe, you can debug this code using 'debugger;' and inspector.

Best Regards,

sefatascan
Posts: 3
Joined: 10 Sep 2020, 09:16

14 Sep 2020, 09:35

I checked the id, they are unique. But in debugging, I saw like that when I was clicked #menuform\:j_idt52_1_0

Code: Select all

 var menucookie = $.cookie('avalon_expandeditems'); menucookie = "menuform:j_idt65_2,menuform:j_idt65_2_0,menuform:j_idt53_5,menuform:j_idt53_5_0,menuform:j_idt52_1,menuform:j_idt52_1_0"
Could the problem be caused by here?

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

29 Sep 2020, 12:31

Sorry for the delayed response! Could you please try it after adding an id to <pu:menu>?

Code: Select all

<pu:menu id="myMenu" widgetVar="me" model="#{menuView.model}" />
Best Regards,

sefatascan
Posts: 3
Joined: 10 Sep 2020, 09:16

29 Sep 2020, 15:57

Oh, it worked. better ids render. Thanks.

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

29 Sep 2020, 16:10

Glad to hear, thanks a lot for the update!

Best Regards,

Post Reply

Return to “Avalon - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest