Search code examples
parsingfacebook-likexfbml

FB.XFBML.parse does not reparse FB widgets


I have a function call back on auth.login and would like to reparse my fb:like elements. Other actions are performed during the auth.login callback, and they execute just fine, but the .parse does not! I try executing FB.XFBML.parse(); in the console and it shows undefined and then after three seconds a console message saying 2 XFBML tags failed to render in 30000ms.

Any ideas?


Solution

  • For anyone who happens to run across this question running into the same problem I did...

    Basically what I wanted to do was after a user logged into my website, I wanted to refresh the 'Like' button iFrame to reflect such. FB.XFBML.parse(); was only resulting in errors...so I thought "Maybe I'll just refresh the iFrame?" and since I am using jQuery as my framework - I figured I'd stick with it.

    So, here's what I ended up doing:

    FB.Event.subscribe('auth.login', function(response) {
        if(response.status == 'connected') {
            $("#login_fb").hide(); // was already doing this part
            $('#like_fb > span > iframe').attr('src', function(i,val) { return val; }); // this is what I wanted to refresh
            //FB.XFBML.parse(); -- THIS WAS GENERATING AN ERROR
        }
    });
    

    Hopefully this will help someone else!