Skip to content

Instantly share code, notes, and snippets.

@makyo
makyo / backbone_pushstate_router.js
Created July 18, 2012 02:51 — forked from tbranyen/backbone_pushstate_router.js
hijack links for pushState in Backbone
// Use absolute URLs to navigate to anything not in your Router.
// Only need this for pushState enabled browsers
if (window.history.pushState) {
// Use delegation to avoid initial DOM selection and allow all matching elements to bubble
$(document).delegate("a.push", "click", function(evt) {
// Get the anchor href and protcol
var href = $(this).attr("href");