Skip to content

Instantly share code, notes, and snippets.

@jls
Created October 29, 2010 14:21
Show Gist options
  • Save jls/653637 to your computer and use it in GitHub Desktop.
Save jls/653637 to your computer and use it in GitHub Desktop.
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