topbar-menu : open in mobile

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

28 Mar 2017, 15:39

Hi,

i'd like to automatically open topbar-menu items (add active-top-menu css) on mobile devices.
In other words: when the app is shown on mobile devices the three dots button appears. When the users click on it i'd like that the menu items with submenu are automatically open.

Is it possible ?

thanks

Simone
Primefaces 12.0.2, Wildfly 24.0.1, JDK 11

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

03 Aug 2017, 16:18

Can anyone answer this topic, please ?
thanks
Primefaces 12.0.2, Wildfly 24.0.1, JDK 11

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

10 Aug 2017, 12:26

Please try;

Code: Select all

<script type="text/javascript">
    $(function() {
        var topbarItems = $('.topbar-items').children('li'),
        isDesktop = window.innerWidth > 1024;

        if(!isDesktop) {
            topbarItems.addClass('active-top-menu');
        }

        $('#topbar-menu-button').on('click', function() {
            topbarItems.addClass('active-top-menu');
        });

        $(window).resize(function() {
            isDesktop = window.innerWidth > 1024;
            if(isDesktop) {
                topbarItems.removeClass('active-top-menu');
            }
        });
    });
</script>

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

10 Aug 2017, 13:16

It works ! Thank u very much !!
Primefaces 12.0.2, Wildfly 24.0.1, JDK 11

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

10 Aug 2017, 14:37

Glad to hear, thanks for the update!

Post Reply

Return to “Ultima - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests