AddThis

Welcome, Guest Sign In

AJAX & Widget

sdive Apr 12, 2012 04:48AM EDT

Hi guys!

I have a modal dialog on my website that provides share functionality for a certain resource. I can get AddThis to load/work when the first dialog has opened. Future dialogs show no buttons, but an empty counter.

How do I make AddThis work with dynamic content? I have tried multiple things, and Googled intensively:

HTML:
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url="{{url}}" addthis:title="{{title}}" addthis:description="{{description}}">
<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>

First try:
// Prevent jQuery from appending cache busting string to the end of the URL.
var cache = $.ajaxSettings.cache;
$.ajaxSettings.cache = true;
$.getScript('http://s7.addthis.com/js/250/addthis_widget.js#pubid=sdive&domready=1', function() {
if (window.addthis){
window.addthis.ost = 0;
window.addthis.ready();
}
});

// Restore jQuery caching setting.
$.ajaxSettings.cache = cache;

// Second try:
if (window.addthis) {
window.addthis.ost = 0;
window.addthis.ready();
}
$.getScript('http://s7.addthis.com/js/250/addthis_widget.js#pubid=sdive&domready=1', function() {
window.addthis.init();
});

Third try:
if (window.addthis) window.addthis = null;
$.getScript('http://s7.addthis.com/js/250/addthis_widget.js#pubid=sdive&domready=1', function() {
window.addthis.init();
});

Nothing works. Any help?

Up 8 Rated Down
sdive Apr 12, 2012 06:08AM EDT
Yes sir! I've fixed it!

if (window.addthis) {
window.addthis = null;
window._adr = null;
window._atc = null;
window._atd = null;
window._ate = null;
window._atr = null;
window._atw = null;
}
$.getScript('http://s7.addthis.com/js/300/addthis_widget.js#pubid=sdive');

Also, the new 300 labs is _awesome_!

This question is closed to new answers.

Still need help?


General Topics

 

Reference