Skip to content

Instantly share code, notes, and snippets.

@moneill
Created August 10, 2012 04:55
Show Gist options
  • Save moneill/3311159 to your computer and use it in GitHub Desktop.
Save moneill/3311159 to your computer and use it in GitHub Desktop.
History API
$(document).ready(function(){
$("input#search").bindWithDelay("keyup", function() {
term = $(this).val();
form = $(this).parent();
action = form.attr('action') + "?" + form.find('input[name!=utf8]').serialize();
if(term == '' || term.length >= 2){
$.get(action, null, null, 'script');
history.replaceState(null, "", action);
}
}, 150);
$(".pagination a").live('click', function(){
$.getScript(this.href);
history.pushState(null, "", this.href);
return false;
});
$(window).bind("popstate", function () {
$.getScript(location.href);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment