Skip to content

Instantly share code, notes, and snippets.

@brycedorn
Created May 5, 2014 17:40
Show Gist options
  • Save brycedorn/58aec8d09b183aabb954 to your computer and use it in GitHub Desktop.
Save brycedorn/58aec8d09b183aabb954 to your computer and use it in GitHub Desktop.
apply_active_nav hack for bootstrap nav - fixes nav pills not reflecting routes
function apply_active_nav() {
var url = document.URL;
var nav = ['contact','about']; // Populate with all nav li classes
$.each(nav,function(i,val) {
var changed = false;
$('li.active').removeClass('active');
if(url.indexOf(nav[i]) > -1) {
$('li.active').removeClass('active');
$("li."+nav[i]).addClass("active");
changed = true;
return false;
}
if(!changed) {
$("li.home").addClass("active");
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment