Skip to content

Instantly share code, notes, and snippets.

@lustremedia
Forked from thirdender/gist:1725514
Last active August 29, 2015 14:07
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 lustremedia/854b238f3f351f2ea43a to your computer and use it in GitHub Desktop.
Save lustremedia/854b238f3f351f2ea43a to your computer and use it in GitHub Desktop.
// Handle previous/next navigation
$(function() {
// Requires jQuery 1.7+ to utilize the new "on" event attachment
$("#contentPadding").on("click", "a.prev, a.next", function (event) {
$.pjax({
"url": $(this).attr("href"),
"fragment": "#contentPadding",
"container": "#contentPadding",
"complete": function(data) {
// Update the className on the BODY tag
var bodyClass = data.responseText && data.responseText.match(/<body[^>]+class\s*=\s*['"]([^'"]+)/);
if (bodyClass) {
$("body").attr("class", bodyClass[1]);
}
// Reinitialize AddThis if it's inside the loaded fragment
if (window.addthis) {
addthis.toolbox($(".addthis_toolbox").get(0));
addthis.counter($(".addthis_counter").get(0));
}
}
});
event.preventDefault();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment