Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcanfield/3078459 to your computer and use it in GitHub Desktop.
Save jcanfield/3078459 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