I'm using iron-router and twbs:bootstrap in a Meteor project. I'm using a bootstrap navbar but whenever I navigate to a new route while the navbar is expanded, the navbar remains expanded when I get to the new route.
I've tried the solution suggested here: Bootstrap navbar stays expanded on route change but it's not working for me. However, I am not sure that I am implementing it correctly.
In my router.js file I added the following:
var closeNavBar = function() {
var isExpanded = $('.navbar-toggle').attr('aria-expanded') === true;
if(isExpanded) {
$('.navbar-toggle').click();
}
}
Router.onAfterAction(closeNavBar, {except: 'signup'});
What am I missing?
Edit: I tried to add a comment to the referenced question but I don't have enough reputation points to add comments.