I have a side navigation that toggles from left side pretty nicely on small devices. Everything is working perfect except when you click on a link in the sidebar; I wan't the navbar to hide and show the content div, but it's stuck and you have to click the toggle-button to remove the sidebar. What should I do to get the navbar to disappear on click without using collapse?
The Button
<button type="button" id="sideBtn" class="navbar-toggle leftToggle" data-
toggle="offcanvas">
<span class="sr-only">Menu</span>
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</button>
This toggles the sidebar JS
$(document).ready(function() {
'use strict';
var trigger = $('.leftToggle'),
isClosed = false;
function buttonSwitch() {
if (isClosed === true) {
trigger.removeClass('is-open');
trigger.addClass('is-closed');
isClosed = false;
}
else {
trigger.removeClass('is-closed');
trigger.addClass('is-open');
isClosed = true;
}
}
trigger.click(function() {
exFunction(this);
buttonSwitch();
});
$('[data-toggle="offcanvas"]').click(function () {
$('#sideNav').toggleClass('toggled');
});
});
The exFunction() just makes the hamburger to an X.