Facebook评论插件仅在刷新后显示 [英] facebook comments plugin showing only after refresh

查看:49
本文介绍了Facebook评论插件仅在刷新后显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Facebook评论插件.

I am trying to use the facebook comments plugin.

我有此代码,我在打开< body> 标记后添加了该代码,并在关闭</body> 之前尝试过,如建议的

I have this code, I have added after the opening <body> tag and also tried before de closing </body> like suggested here

<div id="fb-root"></div>
        <script>(function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0];
          if (d.getElementById(id)) return;
          js = d.createElement(s); js.id = id;
          js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=MY_APP_ID&version=v2.0";
          fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));
        </script>

在显示"页面上,我有< div class ="fb-comments" data-href =<%= request.original_url%>"data-numposts ="5" data-colorscheme ="light"></div>

And on the 'show' page I have <div class="fb-comments" data-href="<%=request.original_url %>" data-numposts="5" data-colorscheme="light"></div>

问题在于,该插件仅在刷新页面时显示,而在通过相同站点的链接访问页面时不显示.

The problem is that the plugin only shows when I refresh the page, not when I access the page through a link from the same site.

我发现与turbolinks有关,我将其卸载并工作了,我想找到一个安装了turbolinks的解决方案.我尝试了此解决方案,但无法没用

I discovered is has to do with turbolinks, I uninstalled it and it worked, I would like to find a solution with turbolinks installed. I tried this solution but couldn't make it work

推荐答案

我遇到了同样的问题.您需要关闭您的turbolinks.转到人们用来访问该页面的链接,然后在该页面将其关闭.例如:

I had same problem. You need to turn off your turbolinks. Go the link where people are using to access the page and turn it off there. For example:

<%= link_to 'Use', model, class: "btn btn-primary", :"data-no-turbolink" => true %>

:"data-no-turbolink" =>是

:"data-no-turbolink" => true

将为您执行此操作.将JS与Rails结合使用时,这是一个已知的问题.

will do this for you. It's a known problem when combining JS with Rails.

这篇关于Facebook评论插件仅在刷新后显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆