Created
April 1, 2013 15:23
-
-
Save sadjow/5285546 to your computer and use it in GitHub Desktop.
Dynamic load addthis tag after ajax calls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ajaxStop(function() { | |
if (window.addthis) { | |
window.addthis = null; | |
window._adr = null; | |
window._atc = null; | |
window._atd = null; | |
window._ate = null; | |
window._atr = null; | |
window._atw = null; | |
} | |
return $.getScript("http://s7.addthis.com/js/300/addthis_widget.js#pubid=sdive"); | |
}); |
addthis.layers.refresh();
https://www.addthis.com/academy/using-dashboard-configuration-tools-dynamically/
(function(a, b, x) {
var s = document.createElement("script");
s.onload = function() {
setTimeout(function() {
if (typeof(jQuery) !== "undefined") {
jQuery(document).ajaxStop(function() {
if (typeof(window.addthis) === "object" && typeof(window.addthis.layers) === "function" && typeof(window.addthis.layers.refresh) === "function") {
window.addthis.layers.refresh();
}
})
}
}, 300)
};
s.src = "//s7.addthis.com/js/300/addthis_widget.js#pubid=0000000000000000";
document.getElementsByTagName("head")[0].appendChild(s);
})(document, "script", undefined);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this work when there are more than one instances of AddThis on the page?