menu highlight

aragorn
Posts: 3765
Joined: 29 Jun 2013, 12:38

29 Jun 2017, 07:53

I couldn't replicate this issue. Which Ultima version are you using?

sistemaslume
Posts: 12
Joined: 17 May 2016, 19:13

20 Nov 2017, 15:31

Hi, we use version 1.0.5 and have the same problem reported by wandyer

Any sugestions??
wandyer wrote:
27 Jun 2017, 05:32
aragorn wrote:
13 Jun 2017, 10:18
Could you please try the following code?

Code: Select all

<script type="text/javascript">
    //<![CDATA[
    $(document).ready(function() {
        var $this = PF('me');
        if($this) {
            var pathname = window.location.pathname;
            if(pathname.indexOf('.xhtml') > 0) {
                var activeLink = $this.menulinks.filter('[href^="' + pathname + '"]');
                $this.expandedMenuitems = [];
                $this.clearMenuState();

                var item = activeLink.parent('li');
                $this.addMenuitem(item.attr('id'));
                addParentItems($this, item);
                rc();
            }
        }
    });

    function addParentItems($this, item) {
        if(item && item.length) {
            var parent = item.parents('li:first');
            $this.addMenuitem(parent.attr('id'));
            if(!parent.parent('ul').hasClass('ultima-menu')) {
                addParentItems($this, parent);
            }
            else {
                return;
            }
        }
        return;
    }
    //]]>
</script>
//menu.xhtml

Code: Select all

<h:form id="menuform"> 
   ....
   <p:remoteCommand name="rc" update="menuform:menu" />
                                     
   <pu:menu id="menu" widgetVar="me">
    ..
The line:

Code: Select all

rc();
makes any top-bar item stop working for me, including the main menu button.

If I remove that line, they start working again but the menus are not highlighted anymore when I open the page from a URL.

My menu.xhtml:

Code: Select all

...
<p:remoteCommand name="rc" update="menuform:menu" />

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

wandyer
Posts: 7
Joined: 15 Dec 2016, 02:09

24 Nov 2017, 19:46

sistemaslume wrote:
20 Nov 2017, 15:31
Hi, we use version 1.0.5 and have the same problem reported by wandyer

Any sugestions??
wandyer wrote:
27 Jun 2017, 05:32
aragorn wrote:
13 Jun 2017, 10:18
Could you please try the following code?

Code: Select all

<script type="text/javascript">
    //<![CDATA[
    $(document).ready(function() {
        var $this = PF('me');
        if($this) {
            var pathname = window.location.pathname;
            if(pathname.indexOf('.xhtml') > 0) {
                var activeLink = $this.menulinks.filter('[href^="' + pathname + '"]');
                $this.expandedMenuitems = [];
                $this.clearMenuState();

                var item = activeLink.parent('li');
                $this.addMenuitem(item.attr('id'));
                addParentItems($this, item);
                rc();
            }
        }
    });

    function addParentItems($this, item) {
        if(item && item.length) {
            var parent = item.parents('li:first');
            $this.addMenuitem(parent.attr('id'));
            if(!parent.parent('ul').hasClass('ultima-menu')) {
                addParentItems($this, parent);
            }
            else {
                return;
            }
        }
        return;
    }
    //]]>
</script>
//menu.xhtml

Code: Select all

<h:form id="menuform"> 
   ....
   <p:remoteCommand name="rc" update="menuform:menu" />
                                     
   <pu:menu id="menu" widgetVar="me">
    ..
The line:

Code: Select all

rc();
makes any top-bar item stop working for me, including the main menu button.

If I remove that line, they start working again but the menus are not highlighted anymore when I open the page from a URL.

My menu.xhtml:

Code: Select all

...
<p:remoteCommand name="rc" update="menuform:menu" />

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

I fixed that problem, but can't remember exactly what I did. I know that I ended up making significant changes to that script provided by argon, because I wanted some custom behaviours.

But I think what fixed the issue of the topbar, I added ignoreAutoUpdate="true" to the p:remoteCommand

Like this:

Code: Select all

<p:remoteCommand name="rc" update="menu" ignoreAutoUpdate="true"/>
If it doesn't work, then I'll provide my script to highlight the menus dynamically

wandyer
Posts: 7
Joined: 15 Dec 2016, 02:09

24 Nov 2017, 20:01

I just tested without ignoreAutoUpdate="true" , and it still works. Now I think I used that property to fix something else.

I reverted the changes on most of my classes and I can't reproduce this issue again on version 1.1, so I'm not so sure what caused it.

Post Reply

Return to “Ultima - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest