Skip to content

Instantly share code, notes, and snippets.

@foca
Created March 12, 2011 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foca/867359 to your computer and use it in GitHub Desktop.
Save foca/867359 to your computer and use it in GitHub Desktop.
This is how awesome history.js is -> it just works.
$(window).bind("statechange", function() {
var state = History.getState();
load(state.url, false);
});
function load(url, push) {
if (push === true || push === undefined)
History.pushState(null, null, url);
$.ajax({
url: url,
dataType: "script html"
}).success(function(response) {
$("#results").html(response);
});
}
searchForm.submit(function() {
load(this.action + "?" + searchForm.serialize());
return false;
});
$("#multiple-choices a").live("click", function() {
load(this.href);
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment