Serenity Theme - Menu Sidebar cookie context

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
cristiandean
Posts: 5
Joined: 20 Jan 2017, 14:43

22 Nov 2017, 18:12

I recently bought the Serenity theme from primefaces and I'm having a context problem. Apparently the menu saves in a cookie containing the menu ID on the form. However, since I have several contexts using the theme, when I go from one context to another, the saved cookie refers to the previous context. Example:

I click on the "manager" menu item in Context1
/Context1/manager.xhtml

When I go to the index of Context2, the state of Context1 is saved.
/Context1/manager.xhtml

I do not know if I could explain it very clearly. Thank you very much in advance.

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

23 Nov 2017, 13:24

Could you please attach your sidebar.xhtml for us to replicate?

cristiandean
Posts: 5
Joined: 20 Jan 2017, 14:43

23 Nov 2017, 13:29

I'm using default sidebar of primefaces serenity

https://www.primefaces.org/layouts/serenity

just: <pm:menu model="#{menuController.menuModel}"></pm:menu>

Javascript: https://www.primefaces.org/serenity/jav ... ity-layout

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

23 Nov 2017, 13:40

I still couldn't replicate it. You use model menu. Please attach a sample code. OR do you see your issue in live demo? If yes, what do I need to do to see your issue?

cristiandean
Posts: 5
Joined: 20 Jan 2017, 14:43

23 Nov 2017, 13:51

Look at this part of the javascript code

Code: Select all

 restoreMenuState: function() {
        var menuCookie = $.cookie('serenity_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();
                    }
                }
            }
        }
        
        var sidebarCookie = $.cookie('serenity_menu_static');
        if(sidebarCookie) {
            this.wrapper.addClass('layout-wrapper-static layout-wrapper-static-restore');
        }
    },
The javascript saves in a cookie the current state of the menu (saving the element ID). However as the cookie is shared in all contexts, when I change context the menu saved the state (active menu) of the previous context, understand?

If you still have a question, I can record a video of it and send it to you.

Post Reply

Return to “Serenity - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests