Skip to content

Instantly share code, notes, and snippets.

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 iamjwc/e2008db21fda6f73792f to your computer and use it in GitHub Desktop.
Save iamjwc/e2008db21fda6f73792f to your computer and use it in GitHub Desktop.
<script type="text/javascript">
// Make the back button work on the search page.
$(function() {
var addPushState = function() {
// When a link in the pager is clicked, add the new url
// to the pushState to make the back button work.
$('.pager li a').click(function() {
history.pushState({}, '', $(this).attr('href'));
return true;
});
};
// Store old callback to use later
var oldAjaxViewResponse = Drupal.Views.Ajax.ajaxViewResponse;
Drupal.Views.Ajax.ajaxViewResponse = function(target, response) {
// Call the original Drupal callback.
oldAjaxViewResponse(target, response);
// Add the click handler to make pushState work.
addPushState();
};
// Add the click handler to make pushState work.
addPushState();
// When the user hits the back button, reload the page.
window.addEventListener("popstate", function(e) {
document.location.reload();
});
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment