How to close (hide) the FBML dialog using the new Facebook SDK?

I spent four hours today, and several hair tried to solve this problem, but could not.

We use facebook.connectto authorize users on our website and perform various actions. One of these actions should trigger fbml:dialog, I decided to use the new JavaScript SDK. Here is the function I'm using:

function popupModalWindow(cat) {
    var oldSize = FB.UIServer.Methods["fbml.dialog"].size;
    FB.UIServer.Methods["fbml.dialog"].size = {width: 402, height: 112};
    //FB.UIServer.id = FB.UIServer._active[id];

    var messages = {
        interesting:  '<p>By submitting my entry, I confirm that I have obtained permission from the persons whose picture and/or voice appears in my entry for use and publication in this contest as outlined in the Official Rules [link]</p>'
    };
    // alert(messages[cat]);
    FB.ui(
        {
            method: 'fbml.dialog',
            //id: 'ololo',
            display: 'dialog',
            width: 402,
            height: 112, /**/ //Should work that way according to the API reference
            size : {width: 402, height: 112},
            fbml: '<link rel="stylesheet" href="http://rentatext.mygrate.biz/styles.css"/><div class="modal-white" style="width: 402px;">'+
            '<h6>User Agreement</h6>'+
            '<fb:js-string var="oloe">document.getElementsByTagName("iframe")[0].id;</fb:js-string>'+
            '<div class="inner">'+messages[cat]+' <a class="fb-close" onclick="FB.UIServer._active[oloe].close()">i agree</a></div></div>'
            ,
        },
        function() {
            alert(1);
        }

    );
    console.debug(FB.UIServer);
}

Unfortunately, the designer made these modal windows a gray background, and some users may not notice the default close button in the upper right corner of the dialog box. I need to bind an event to some custom element that will close this dialog. I tried different approaches, but none of them worked.

: "a138033292903816_FB ", a.fb-close onclick. , - , , .

+3
2

. . : FB , FB JS FB.ui:

FB.Dialog.remove(FB.Dialog._active);

, - JS iframe:

parent.FB.Dialog.remove(parent.FB.Dialog._active);

+2

Facebook javascript . . , CSS ?

0

Source: https://habr.com/ru/post/1758930/


All Articles