• Hello everyone,
    I’m trying to collapse nav bar after click , in one page template.

    I have set this script below , but unfortunately with last version of undestrap , doesn’t work.

    $('.navbar-toggleable-md').click(function () {
        var navbar_toggle = $('.navbar-toggle');
        if (navbar_toggle.is(':visible')) {
            navbar_toggle.trigger('click');
        }
    });

    can anyone help me solve?

    thank you
    regards
    Emanuele

Viewing 15 replies - 1 through 15 (of 15 total)
  • Hi!
    There where several changes during the update from BS4 Alpha 4 to Alpha 5.

    Could you post the HTML markup you trying to manipulate with? Is it in a child theme?

    The markup for the “hmaburger icon” menu toggler now looks like:

    <button class="navbar-toggler hidden-sm-up" type="button" data-toggle="collapse"
    					        data-target=".exCollapsingNavbar" aria-controls="exCollapsingNavbar" aria-expanded="false"
    					        aria-label="Toggle navigation"></button>
    Thread Starter epd

    (@epd)

    HI holger1411,
    yes i’m working in child-theme.
    I have change only the hidden class from sm to md in button

    <button class="navbar-toggler hidden-md-up" type="button" data-toggle="collapse"
    					        data-target=".exCollapsingNavbar" aria-controls="exCollapsingNavbar" aria-expanded="false"
    					        aria-label="Toggle navigation"></button>

    and in wp_nav_menu navbar-toggleable-sm

    <!-- The WordPress Menu goes here -->
    				<?php wp_nav_menu(
    					array(
    						'theme_location'  => 'primary',
    						'container_class' => 'collapse navbar-toggleable-sm exCollapsingNavbar',
    						'container_id'    => 'exCollapsingNavbar',
    						'menu_class'      => 'nav navbar-nav',
    						'fallback_cb'     => '',
    						'menu_id'         => 'main-menu',
    						'walker'          => new WP_Bootstrap_Navwalker(),
    					)
    				); ?>
    • This reply was modified 9 years, 4 months ago by epd.
    • This reply was modified 9 years, 4 months ago by epd.
    • This reply was modified 9 years, 4 months ago by epd.

    Hi!
    Sorry, maybe I misunderstood your intention…what you trying to archive instead of the nomral behavior? Can you describe the userflow a bit more?

    Thread Starter epd

    (@epd)

    Hi,
    in last versione of Understrap you introduce template “Vertical One Page”.
    I have set it to my site with navbar fixed top.

    When browsing from a mobile , if you click on a menu item, you’ll see that the menu does not collapse.
    You can see my demo site and try it here http://test.dancinatelier.shoes

    what I’m trying to do myself is to collapse the menu after click

    please let me know if all clear now.

    thank you
    best regards
    Emanuele

    Hi!
    Bug was reported here:
    https://github.com/holger1411/understrap/issues/171
    and (hopefully) already fixed in the pre-release version 0.5.1
    available here:
    https://github.com/holger1411/understrap/releases/tag/0.5.1

    Thread Starter epd

    (@epd)

    Hi,
    I have update 0.5.0 with pre-release version 0.5.1
    but unfortunately nav bar does not collapse after the click.

    please check here http://test.dancinatelier.shoes

    thank you
    best regards
    Emanuele

    Works here perfectly.
    Is JS activated in your Browser?
    And make sure you completely delete your browser cache.

    Thread Starter epd

    (@epd)

    work perfectly my demo site?

    yes i have js active and i have delete all cache…i have also tested it in another pc and mac , but it doesn’t work!

    Thread Starter epd

    (@epd)

    in pre-release you sent to me, the file understrap/js/vertical-one-page.js is the same as release 5.0

    • This reply was modified 9 years, 4 months ago by epd.

    Hi!
    Thats how it looks like here:
    how it looks here

    And thats the diff between both file versions:
    https://github.com/holger1411/understrap/commit/ff75a19e069a9f5a1596e28646603b04fd5b01ee

    Okay, my gif tool did not recorde the coursor…but it collaps on click fluidly

    Thread Starter epd

    (@epd)

    i’m sorry but maybe i have explained bad my problem.
    Please click on “about” or “portfolio” or “contact” menu , you will see the menu does not collapse!

    Thread Starter epd

    (@epd)

    that how look my website

    gif

    Maybe know ive understand your intention…
    The main menu just collapse if you hit the button, not if you click a link.

    Yes, but thats how it should work.
    On a one pager it makes sense having the menu open like a TOC (table of content) element and thats how the Bootstrap menu work/handle onsite links.
    Without that you have no kind of nav indicator and you don´t know where you are.

    Just the combination with the fixed navbar isn´t perfect because you have to close the menu before you could start reading.
    But in the other case you have to open the menu again and again if you wanna move from one point to another.

    So from a UX point of view this behavior isnt a bug, more a “feature”.

    Thread Starter epd

    (@epd)

    ok thanks for your advice!

    Yes I think there are pros and cons either way!
    I think as a future is better the menu collapse after click.
    In most one page sites that I see online that have fixed navigation bar on top , this feature is enable.
    This only my point of view!:-)

    thank you for your support

    best regards
    Emanuele

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘collapse nav bar on click’ is closed to new replies.