Skip to content

Instantly share code, notes, and snippets.

View jabbett's full-sized avatar

Jonathan Abbett jabbett

View GitHub Profile
@jabbett
jabbett / backbone_pushstate_router.js
Last active December 15, 2015 04:09 — forked from tbranyen/backbone_pushstate_router.js
Updated protocol check to respect javascript: pseudo-protocol and hash links (#foo) Updated to support IE
// Use absolute URLs to navigate to anything not in your Router.
// Note: this version works with IE. Backbone.history.navigate will automatically route the IE user to the appropriate hash URL
// Use delegation to avoid initial DOM selection and allow all matching elements to bubble
$(document).delegate("a", "click", function(evt) {
// Get the anchor href and protcol
var href = $(this).attr("href");
var protocol = this.protocol + "//";
// Ensure the protocol is not part of URL, meaning its relative.