Programmatically toggle bootstrap 3 navigation bar
As you said, the event will run a modal.
So, when your modal ( called yourModal ) is showing (before showing), just hide the menu :
JS :
$('.yourModal').on('show.bs.modal', function(){
$('.navbar-collapse').collapse('hide');
});
Here are the docs :
http://getbootstrap.com/javascript/#collapse
http://getbootstrap.com/javascript/#modals-usage
After a little bit of help from @Jahnux73 I figured it out myself. So the only thing I had to do is to add :
data-toggle="collapse" data-target=".navbar-ex1-collapse"
to the specific link that I wanted to toggle the navbar. so the link now looks like following:
<a href="#" id="online-offline" data-toggle="collapse"
data-target=".navbar-ex1-collapse" toggle="offline">
<span class="glyphicon glyphicon-off"></span> Go offline
</a>