Skip to content

Instantly share code, notes, and snippets.


Shane Harter shaneharter

View GitHub Profile
shaneharter / backbone_pushstate_router.js
Last active Aug 29, 2015 — forked from wololodev/backbone_pushstate_router.js
Play nice with Backbone.history.root when attaching pushstate click handler
View backbone_pushstate_router.js
// Only need this for pushState enabled browsers
if (Backbone.history && Backbone.history._hasPushState) {
var $document = $(window.document);
var openLinkInTab = false;
// Links like <a href="some/thing/here"> are relative to the page.
// We want to run these links thru the router
var is_relative_to_page = function(href) {
return href.match(/^\/|(http:|https:|ftp:|mailto:|javascript:)/) === null;
View tap.js
Object.defineProperty(Object.prototype, 'tap', {
value: function(fun){ this );
return this;
enumerable: false
// Usage:
// a = [];
You can’t perform that action at this time.