I've got a views page that can be re-freshed via AJAX.

My AddThis links are included included in the links and appear on the original page load. However, when I update the views page via AJAX my AddThis images/links don't appear.

Any idea to how this can be fixed?

Thank you.

Comments

victoria_b’s picture

Oh, should add that I'm using AddThis Toolbox

vesapalmu’s picture

Status: Active » Closed (won't fix)

We are not currently supporting Toolbox. It's only supported in D7 4.x version. However if you figured out what was the problem I would love to know, we might run into this soon with Addthis 4.x.

ptrl’s picture

A ugly fix would be to do something like this in a javascript file

Drupal.behaviors.addThisAJAX = function(context) {
  var script = 'http://s7.addthis.com/js/250/addthis_widget.js#domready=1';
  if (window.addthis){
    window.addthis = null;
  }
  $.getScript( script );
};
marcoka’s picture

are you sure that this works.
i added this script to my page and nothing changes. Using views_infinite_scroll for ajax stuff via views

marcoka’s picture

my bad above is d6 code, i use D7

for d7 use. just add the js file via .info and its fixed

(function ($) {
    Drupal.behaviors.slider = {
        attach:function(context) {
            var script = 'http://s7.addthis.com/js/250/addthis_widget.js#domready=1';
            if (window.addthis) {
                window.addthis = null;
            }
            $.getScript(script);

        }

    };
}(jQuery));
marcoka’s picture

i added this to the documentation. i hope that is ok.

http://drupal.org/node/418356

jlbellido’s picture

Since some weeks ago #4 doesn't work for me . I modified #4 like this :

Drupal.behaviors.addThisAJAX = function(context) {
        var protocol = location.protocol;
        var script = protocol + '//s7.addthis.com/js/250/addthis_widget.js#domready=1';
        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( script, function() {
            addthis.init();
        } ); 
    };    

Now it works again , i hope that this will be helpful.
Regards!

oxyc’s picture

AddThis has functions to manually intialize specific share boxes. I havent found any proper documentation about which exist but the two I needed in my own use case are toolbox and counter.

--- a/sites/all/modules/contrib/addthis/addthis.js
+++ b/sites/all/modules/contrib/addthis/addthis.js
@@ -19,6 +19,8 @@
           if (context != window.document && window.addthis != null) {
             window.addthis.ost = 0;
             window.addthis.ready();
+            window.addthis.toolbox('.addthis_toolbox');
+            window.addthis.counter('.addthis_counter');
           }
         }
       }