Question

Im using addThis for create share button on a project, email and twitter work fine but Linkedin and Facebook do not work. I understand they need opengraph to work but what if your content is javascript driven? At the moment the Facebook popup simply shows (no title).. Has anyone else been able to get facebook share to work for addThis on AJAX pages?

Thank you in advance.

This is the script Im using on my page at the moment.

 <!--- share --->
                <div class="share-buttons" id="toolbox-5"></div>
                <script type="text/javascript">
                var tbx = document.getElementById("toolbox-5"),
                    svcs = {
                        email: 'Email',
                        print: 'Print',
                        // facebook: 'Facebook',
                        twitter: 'twitter',
                        // linkedin: 'linkedin'
                    };

                for (var s in svcs) {
                    tbx.innerHTML += '<a class="addthis_button_'+s+'">'+svcs[s]+'</a>';
                }
                addthis.toolbox("#toolbox-5"
                    , {}
                    , {url: "www.urlofthing.com"
                    , title: "title of thing"});
                // );
                </script>
                <!--- share --->

An example of the URL my application uses..

http:domain.com/dir/section/#!/3/1017/
Was it helpful?

Solution

After the new content has been loaded, try forcing the url via the specific AddThis method:

addthis.update('share', 'url', window.location.href); // re-parse the url
addthis.ready(); // re-render the buttons.

This has been a good starting point for me to solve the same problem you describe:

AddThis buttons wont update to include fragment (#Hash Tag)

Bye!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top