Skip to content
This repository has been archived by the owner on Sep 25, 2021. It is now read-only.

Facebook Customer Chat issue with Turbolinks 5 on Rails #596

Open
totycos opened this issue Jan 14, 2021 · 2 comments
Open

Facebook Customer Chat issue with Turbolinks 5 on Rails #596

totycos opened this issue Jan 14, 2021 · 2 comments

Comments

@totycos
Copy link

totycos commented Jan 14, 2021

Every time I change pages, fb-root generates a new fb_dialog without removing the old one.
Here is my code:

application.js

// Load Facebook SDK for JavaScript 

function FBInit() {
  FB.init({
    appId      : '<XXXXXXXXXX',
    xfbml      : true,
    version    : 'v9.0'
  });
};

$(document).ready(function(){
  $.getScript( "https://connect.facebook.net/fr_FR/sdk/xfbml.customerchat.js", FBInit);
});

$(document).on('turbolinks:load', function(event){
  if (typeof FB !== "undefined" && FB !== null) {
    FB.XFBML.parse();
  }
});

$(document).on("turbolinks:before-cache", function() {
    $('[data-turbolinks-no-cache]').remove();
});

application.html.erb

<body> 
          <!-- Facebook Customer chat Plugin -->
          <div id="fb-root" data-turbolinks-permanent></div>

          <div class="fb-customerchat" data-turbolinks-no-cache attribution=setup_tool page_id="XXXXXXXXX"
            theme_color="#0A7CFF" greeting_dialog_display="hide" logged_in_greeting="Salut, tu peux me poser des questions et faire des remarques ici 🙂👇   "
            logged_out_greeting="Salut, tu peux me poser des questions et faire des remarques ici 🙂👇  ">
          </div>

Capture d’écran 2021-01-14 à 21 17 26

@zolzaya
Copy link

zolzaya commented Apr 29, 2021

Hey @totycos did you found a solution? I have a same problem :(

@nam3886
Copy link

nam3886 commented May 22, 2021

i have a same problem with fb-customchat
Capture
then I add this code
Capture2
everything is working fine

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants