本文介绍了如何使用turbilinks rails 4添加此工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在这方面工作了将近一天,并且无法弄清楚如何使用turbolinks和rails 4来完成这项工作。我添加此代码

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 -->

如何使其与turbolink兼容,以便它在每个页面上显示而无需重新加载页面或禁用turbolinks

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

推荐答案

我终于得到它了解这个

<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>

这篇关于如何使用turbilinks rails 4添加此工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 15:40