Handle push state entirely

This commit is contained in:
John Crepezzi 2011-11-18 16:22:00 -05:00
parent 4f00d3c71a
commit 6597dba36d
4 changed files with 56 additions and 9 deletions

View file

@ -39,9 +39,19 @@
<script type="text/javascript">
$(function() {
// Set up
var app = new heist('heist');
app.newDocument();
$('textarea').focus();
// Handle pops
window.onpopstate = function(evt) {
var path = evt.target.location.pathname;
if (path === '/') {
app.newDocument();
}
else {
app.loadDocument(path.substring(1, path.length));
}
};
});
</script>