Skip to content

Instantly share code, notes, and snippets.

@mlynch
Created December 12, 2012 00:05
Show Gist options
  • Save mlynch/4263590 to your computer and use it in GitHub Desktop.
Save mlynch/4263590 to your computer and use it in GitHub Desktop.
$(document).on "click", "a[href^='/']", (event) ->
href = $(event.currentTarget).attr('href')
# Check if the link matches our route
passThrough = href.indexOf('/dash') != 0
# Allow shift+click for new tabs, etc.
if !passThrough && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey
event.preventDefault()
# Remove leading slashes and hash bangs (backward compatablility)
url = href.replace(/^\//,'').replace('\#\!\/','')
# Instruct Backbone to trigger routing events
window.Dashboard.router.navigate url, { trigger: true }
return false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment