Skip to content

Instantly share code, notes, and snippets.

@mattsgarrison
Created January 12, 2012 14:46
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattsgarrison/1600924 to your computer and use it in GitHub Desktop.
Save mattsgarrison/1600924 to your computer and use it in GitHub Desktop.
CoffeeScript and JavaScript results to enhance Twitter Bootstrap navbar's "active" tab for multiple pages (essentially supplanting scrollspy).
// Generated Output from CoffeeScript
jQuery(function() {
var a, b, c, d, e;
d = $(".topbar .nav a"), e = [];
for (b = 0, c = d.length; b < c; b++)
a = d[b], e.push(function(a) {
if (window.location.pathname === a.pathname)
return $(a).parent().toggleClass("active")
}(a));
return e
});
jQuery ->
for link in $(".topbar .nav a")
do (link) ->
if (window.location.pathname == link.pathname)
$(link).parent().toggleClass("active")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment