2013-10-13 23 views
0

我使用AddThis http://www.addthis.com插件在社交網絡上共享我的頁面。我把這段代碼我的網站裏:AddThis按鈕在導航到其他路線後消失

<!-- AddThis Smart Layers BEGIN --> 
    <!-- Go to http://www.addthis.com/get/smart-layers to customize --> 
    <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-xxx"> 
    </script> 

    <script type="text/javascript"> 
     addthis.layers({ 
     'theme' : 'transparent', 
     'share' : { 
      'position' : 'left', 
      'numPreferredServices' : 5 
     } 
     }); 
    </script> 
    <!-- AddThis Smart Layers END --> 

按鈕顯示正常,當我打開我的網站,但之後我瀏覽到其他位置,它們就會消失。即使我回到我的主頁,他們也沒有顯示。只有在我刷新我的網站後,再次出現按鈕。

我試圖用這個解決方案,但似乎我無法得到它的工作:

addthis buttons are disappeared?

謝謝您的幫助。

+0

什麼是您的網站的網址?你使用的是什麼瀏覽器?你有沒有安裝任何插件? – Paul

+0

我的網站仍然不在線。我只使用FullCalendar插件。我正在使用Rails 4和Safari瀏覽器。 – Cristiano

回答

0

現在我已經這樣做了。這是一個非常糟糕的解決方案,但我無法正常工作。我將這些代碼放在我不刷新頁面的所有視圖中。因此,相同的代碼位於主application.html.erb文件中,也位於通過「home」頁面訪問的另外兩個視圖中。

<script type="text/javascript">$(document).ready(function() { 
    var script = 'http://s7.addthis.com/js/300/addthis_widget.js?domready=1#pubid=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' : 5 
      } 
     }); 
    }); 
}); 
</script> 

我知道這是一個非常糟糕的解決方案,因爲我c/p代碼相同。