PrimeBlocks menu

Post Reply
IvanVugi
Posts: 2
Joined: 17 Mar 2019, 12:22

30 Oct 2022, 13:55

Hi,

I am using application shell from one of PrimeBlocks, got navigation working but I can't figure out how to mark active menu item and expand it after navigation if it is a child menu item.
All pages include same template with menu.

Can someone help, is there some examples on how to achieve this?

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

31 Oct 2022, 11:08

Hi,

We use the following js code to active a menuitem according to router in Premium Layout. Maybe, it can help to you;

Code: Select all

...
           var link = this.menu.find('a[href^="' + this.cfg.pathname + '"]');

            if (link.length) {
                var submenu = link.next('ul');
                var parentMenu = menuitem.closest('ul');
                
                submenu.length > 0 && submenu.removeClass('hidden');
                link.addClass('active-menuitem-routerlink');

                if (parentMenu.length) {
                    while (!parentMenu.hasClass('root-menuitem')) { // a custom class for root 'ul' element
                        parentMenu.removeClass('hidden');

                        parentMenu = parentMenu.closest('ul');
                        if (!parentMenu.length) {
                            break;
                        }

                        parentMenu = parentMenu.closest('li');
                    }
                }
  ...
Best Regards,

Post Reply

Return to “PrimeBlocks for PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest