How to do this job with turbine rails 4

I have been working on this for almost the whole day and cannot figure out how to do this work with turbines and rails 4. my code is being added

<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 reloading the page or disabling turbolinks

+1
source share
1 answer

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>
+4
source

Source: https://habr.com/ru/post/1526816/


All Articles