Show / Hide Facebook Chat Plugin

1.5k Views Asked by At

This question has been asked before on other forums but dont see to be able to find an answer the works, so asking again incase anyone can help.

I have the facebook chat plugin on my website www.tiqy.com, which works fine with the following code. The part that doesnt work is "FB.Event.subscribe('customerchat.dialogHide',FB.CustomerChat.hide());". When someone closes the chat I want the whole chat icon to disappear. I have read and tried to follow the facebook documentation, but it doesnt seem to work.

 window.fbAsyncInit = function () {
            FB.init({
                status: false,
                cookie: false,
                xfbml: false,
                version: 'v6.0'
            });
            FB.Event.subscribe('customerchat.dialogHide',
                FB.CustomerChat.hide());

        };

        (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 = 'https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js';
            fjs.parentNode.insertBefore(js, fjs);
        }(document, 'script', 'facebook-jssdk'));</script>
1

There are 1 best solutions below

0
CBroe On
FB.Event.subscribe('customerchat.dialogHide',
  FB.CustomerChat.hide());
};

The syntax of the example they provide in the docs is not correct.

FB.Event.subscribe('customerchat.dialogHide', callback()); – this should not be callback(), because that would call the function right then and there; but only callback instead, to pass the reference to the function.

So try FB.Event.subscribe('customerchat.dialogHide', FB.CustomerChat.hide);