I am adding social share option on the page using Add This.

I have added the code to my phtml file and added the js script in the head, which is working fine.

Also, I have an option to filter data on the select category on the same page. In that case, data is coming from the controller using ajax. everything is working perfectly except social share option.

After selecting the category from dropdown the data filters using ajax, but social share option is not coming.

I think script needs to be the load again for the social share buttons.

social share button add this code:

<div class="addthis_inline_share_toolbox" data-url="<?php echo $baseURL_l.'video#'.$url?>" data-title="<?php echo $video->getVideoTitle(); ?>" addthis:media="<?php echo 'https://img.youtube.com/vi/'.$video->getVideoUrl() ?>/0.jpg" ></div>

and script:

<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5a4219ef9de357a6"></script>

Try to add below code after ajax response.

jQuery(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 jQuery.getScript("http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5a4219ef9de357a6");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.