how to make add this work with turbilinks rails 4
Asked Answered
J

1

1

I have been working on this for almost a day now and cant figure out how to make addthis work wtih turbolinks and rails 4. my add this code is

<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js"></script>
<script type="text/javascript">
    addthis.layers({
        'theme' : 'transparent',
        'share' : {
            'position' : 'left',
            'numPreferredServices' : 6
        },
        'follow' : {
            'services' : [
                {'service': 'facebook', 'id': 'blanckdigital'},
                {'service': 'twitter', 'id': 'blanckdigital'}
            ]
        },
        'whatsnext' : {},
        'recommended' : {}
    });
</script>
<!-- AddThis Smart Layers END -->

How can i make it compatible with turbolinks so that it appears on every page without doing a page reload or disabling turbolinks

Judiciary answered 1/1, 2014 at 1:20 Comment(2)
You're missing a quote after addthis_widget.jsCossack
it was a typo. made correctionsJudiciary
J
4

i finally got it to work with this

<script type="text/javascript">$(document).ready(function() {
    var script = 'http://s7.addthis.com/js/300/addthis_widget.js#pubid=ra-xxx';
    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.layers({
            'theme' : 'transparent',
            'share' : {
                'position' : 'left',
                'numPreferredServices' : 6
            },
            'follow' : {
                'services' : [
                    {'service': 'facebook', 'id': 'blanckdigital'},
                    {'service': 'twitter', 'id': 'blanckdigital'}
                ]
            },
            'whatsnext' : {},
            'recommended' : {}
        });
    });
});
</script>
Judiciary answered 1/1, 2014 at 2:38 Comment(1)
That works :) but any ideas on how to do this for the addthis bar?Selffulfillment

© 2022 - 2024 — McMap. All rights reserved.