clearMenuState

Forum rules
Please note that response time for technical support is within 3-5 business days.
spadovan
Posts: 178
Joined: 05 Jun 2013, 12:04

16 Feb 2017, 15:38

Hi Aragorn, i'd like to reset menu (of sidebar) when i load a certain page.
Reading the forum i found that you said to call

PF('menuWidget').clearMenuState()

But it seem it doesn't work and clearMenuState is not been called.

Could ypu please help me once more ?

Thanks

Simone
Primefaces 12.0.2, Wildfly 24.0.1, JDK 11

spadovan
Posts: 178
Joined: 05 Jun 2013, 12:04

20 Feb 2017, 09:02

I've named my po:menu tag with a widgetvar and calling widgetvar.clearMenuState() works, but it's too late because the menu is already built and only refreshing the page i can see thet the menu is cleared.

How can i force the menu to be clear in current page ?

Thanks
Primefaces 12.0.2, Wildfly 24.0.1, JDK 11

spadovan
Posts: 178
Joined: 05 Jun 2013, 12:04

20 Feb 2017, 16:43

clearMenuState clears the cookie of the state of expanded items but does not clear the "active-item" style from the menu.

I'd like to have a function like menu.clearActiveState() which for a menu walks its children and performs a item.removeClass('active-menuitem');
Primefaces 12.0.2, Wildfly 24.0.1, JDK 11

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

22 Feb 2017, 11:27

Sorry for your late reply, please add the following code into layout.js;

Code: Select all

...
    clearActiveItems: function() {
        var activeItems = this.jq.find('li.active-menuitem'),
        subContainers = activeItems.children('ul');

        activeItems.removeClass('active-menuitem');
        if(subContainers && subContainers.length) {
            subContainers.hide();
        }
    }
...
I'll add this method into next version.

spadovan
Posts: 178
Joined: 05 Jun 2013, 12:04

22 Feb 2017, 11:40

Sorry Aragorn, where do i have to put this code and how do i have to call it ? thanks
Primefaces 12.0.2, Wildfly 24.0.1, JDK 11

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

22 Feb 2017, 11:58

No problem, what PF version are you using?

spadovan
Posts: 178
Joined: 05 Jun 2013, 12:04

22 Feb 2017, 12:00

6.0.15, thanks
Primefaces 12.0.2, Wildfly 24.0.1, JDK 11

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

22 Feb 2017, 12:01

Thanks for the update, please try;

Code: Select all

/** 
 * PrimeFaces Omega Layout
 */
PrimeFaces.widget.Omega = PrimeFaces.widget.BaseWidget.extend({
    
    /* Other methods */
    ...
    
    clearActiveItems: function() {
        var activeItems = this.jq.find('li.active-menuitem'),
        subContainers = activeItems.children('ul');

        activeItems.removeClass('active-menuitem');
        if(subContainers && subContainers.length) {
            subContainers.hide();
        }
    }
    
});
You can use PF('menuWidgetVar').clearActiveItems(); after removing menu state with ...clearMenuState();

spadovan
Posts: 178
Joined: 05 Jun 2013, 12:04

22 Feb 2017, 12:09

it works, thanks again....

Simone
Primefaces 12.0.2, Wildfly 24.0.1, JDK 11

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

22 Feb 2017, 12:13

Glad to hear, thanks for the update! Also, I added this method into next release.

Post Reply

Return to “Omega - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 12 guests