Close bootstrap navigation with iron router

hi there! i am using a standard bootstrap navigation with iron router.

<nav class="navbar navbar-default" role="navigation">
    <div class="container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="#"></a>
      </div>

      <!-- Collect the nav links, forms, and other content for toggling -->
      <div class="collapse navbar-collapse" id="navbar">
        <ul class="nav navbar-nav">
          <li class="nav-item"><a href="{{pathFor 'home'}}">Home</a></li>
          <li class="nav-item"><a href="{{pathFor 'nutrition'}}">Nutrition</a></li>
          
        </ul>
      </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
  </nav>

#################
when the user clicks the content changes, but the navigation remains ‘open’. what do i have to add to the links to close the navigation on click?

thanks in advance!!

hi! any help would be highly appreciated.
thx!

With bootstrap generally you have to add a class. Look the right class up in the docs.

Could some something like:

<div class="collapse navbar-collapse {{#if hideNav}}in}}/if" id="nabber">

Where you need a helper which returns true/false depending on whether you want to show or hide it.

Alternative is working with the classes:

<a href="{{pathFor 'home'}}" data-toggle="collapse" data-target="#navbar">Home</a>

You would have to test if that’s working and not conflicting.

1 Like

data-toggle=“collapse” in the link works! thanks for the tip!!!