I'm using the AddThis Wordpress plugin to include share buttons underneath each post in an AJAX theme, and am having trouble getting the code right.
I inserted the following code in the custom button field on the settings page:
<div class="addthis_toolbox addthis_default_style" id="toolbox">
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a>
<a class="addthis_button_preferred_4"></a>
<a class="addthis_button_compact"></a>
</div>
Then in the post loop in the main page PHP file I have this:
<script>
var tbx = document.getElementById("toolbox"),
svcs = {email: 'Email', print: 'Print', facebook: 'Facebook', expanded: 'More'};
for (var s in svcs) {
tbx.innerHTML += '<a class="addthis_button_'+s+'">'+svcs[s]+'</a>';
});
function ReinitializeAddThis() {
if (window.addthis) {
window.addthis.toolbox("#toolbox");
}
}
</script>
<iframe style="display: none;" onload="ReinitializeAddThis();"></iframe>
The buttons will only load sporadically, and disappear after a refresh. I'm also getting the error Uncaught ReferenceError: ReinitializeAddThis is not defined which is confusing... I'd really appreciate any insight and I apologize if anything is unclear. Thanks!
<iframe style="display: none;" onload="ReinitializeAddThis();"></iframe>- what is this? - montrealistReinitializeAddThis();function. (edited link, having trouble with the markdown) - bedlogic