Created
October 29, 2010 14:21
-
-
Save jls/653637 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = $.sammy(function(){ | |
this.element_selector = '#content'; | |
this.get(/\#!\/(.*)/, function(context){ | |
this.partial('/' + this.params['splat']); | |
}); | |
}); | |
$(document).ready(function(){ | |
app.run('#!/'); | |
// We will setup all of our links in the | |
// application to use normal paths. | |
// Then in this click handler we will convert | |
// them to hash links. | |
$('a').live('click', function(event){ | |
var url = $(this).attr('href'); | |
if(url.indexOf('http') == -1){ | |
url = '#!' + url; | |
window.location = url; | |
}else{ | |
window.open(url); | |
} | |
return false; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment