Torads
Torads

Reputation: 69

Bootstrap 3 after navbar collapse, toggle wont reopen nav

I was trying to solve an issue where when I clicked on a navbar menu item in mobile view the navbar remained expanded. this didn't work for me as my menu item was pointing to a div ID. I read here of a solution to add the below to my a href tag.

data-toggle="collapse" data-target=".navbar-collapse" 

this did not work for me but I could get it to work using a javascript fix I found on github https://github.com/twbs/bootstrap/issues/12852

$(document).on('click','.navbar-collapse.in',function(e) {
if( $(e.target).is('a') ) {
    $(this).collapse('hide');
}
});

Now the problem is that after the navbar was hidden I could not open it a second time.

Anyone else have this problem or a solution?

Upvotes: 0

Views: 411

Answers (1)

Kami
Kami

Reputation: 19407

Change the collapse parameter from hide to toggle.

$(this).collapse('toggle');

See more at bootstrap docs.

Upvotes: 0

Related Questions