Collapse menu from code

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
arco
Posts: 11
Joined: 25 Jul 2017, 09:19
Location: Netherlands

25 Jul 2017, 15:21

Some of my menu items are just Ajax updates, how to collapse the menu from code (like clicking on the hamburger icon) because the page isn't reloaded the menu keeps unfolded after clicking the menu item.
Thanks in advance,
Arco

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

31 Jul 2017, 07:46

Please try;

Code: Select all

<pa:tabMenu widgetVar="myTabMenu">
      ....
	<p:submenu ...>
                 <p:menuitem onclick="closeMenu()" .../>
       </p:submenu>
       ...
</pa:tabMenu />

//JS code
<script type="text/javascript">
            function closeMenu() {
                var $this = PF('myTabMenu');
                if($this) {
                    $this.tabMenu.find('.menu-button').trigger('click');
                }
            }
</script>

arco
Posts: 11
Joined: 25 Jul 2017, 09:19
Location: Netherlands

01 Aug 2017, 16:31

That works, thanks !!!

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

02 Aug 2017, 08:18

Glad to hear, thanks for the update!

Post Reply

Return to “Barcelona - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests