Support

Please note that AddThis will be closed for the Labor Day holiday August 30th, 2014 to September 1st, 2014.
Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

AddThis and Ajax

metafa Jan 02, 2012 @ 11:25AM EST
Hello!

I need this question answered:

Trying to load a page via ajax. There is no page reloading, page navigation happens with hashtags (#) .. so the first time (after a page reload) the addThis-plugin is rendered well, the second time it won't even show up or shows up crippled. What can I do about that? Please help!! My code:

<div id="fillme"></div>
<script>
var html = '<div class="addthis_toolbox addthis_default_style addthis_32x32_style"><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><a class="addthis_counter addthis_bubble_style"></a></div>';

var cache = jQuery.ajaxSettings.cache;

jQuery.ajaxSettings.cache = true;
jQuery.getScript('http://s7.addthis.com/js/300/addthis_widget.js#pubid=PUB_ID?domready=1');

// Restore jQuery caching setting
jQuery.ajaxSettings.cache = cache;
$('#fillme').html(html);
</script>

I have struggeld hours now.. Someone can help? Thanks!

1 Community Answers

Best Answer
metafa Jan 02, 2012 @ 12:50PM EST

Found the answer myself:

function ReinitializeAddThis(){
if (window.addthis){

window.addthis.ost = 0;
window.addthis.ready();
}
}

$.ajax({
url: "http://s7.addthis.com/js/300/addthis_widget.js#PUB_ID",
dataType: 'script',
success: function(){
ReinitializeAddThis();
}
});

@AddThis-devs: PLEASE think of ajax devs! I was really searching for this solution for HOURS....


This question has received the maximum number of answers.

help@addthis.com
http://assets02.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete