Code Monkey home page Code Monkey logo

Comments (6)

pc035860 avatar pc035860 commented on August 18, 2024

Did you load FB JS SDK yourself by adding this: (which is from the official doc)

<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : 'your-app-id',
      xfbml      : true,
      version    : 'v2.4'
    });
  };

  (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";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));
</script>

to the web page?

angular-easyfb wraps the SDK loading process into it, so there's no need to load the SDK by yourself. And you can access the SDK loading function with getLoadSDKFunction / setLoadSDKFunction.

from angular-easyfb.

JohnBernardsson avatar JohnBernardsson commented on August 18, 2024

No I didn't... But now that you say it, it is possible that the SDK is already loaded in the project. I am using this in a Meteor project, that includes a package for facebook login, so I think that package might be loading the SDK before ezfb does it...
Thing is, if I don't call the init on ezfb, I can't use the ezfb like button directive, right? (or it is not a directive?).
Now I have more doubts than before 😅

from angular-easyfb.

JohnBernardsson avatar JohnBernardsson commented on August 18, 2024

So it seems that is the problem. Somewhere, at some point (I couldn't figure out where or how), the SDK is already loaded in my project. And the FB.Init function called.

What I did is simply set the initfunction like this:

var myInitFunction = ['$window', '$rootScope', 'ezfbInitParams', function ($window, $rootScope, ezfbInitParams) {
    //$window.FB.init(ezfbInitParams);
    $rootScope.$broadcast('FB.init');
}];

ezfbProvider.setInitFunction(myInitFunction);

Commenting out the initialization line. And that way seems to work, no warning, the like button is loading ok... I hope everything else also works!

Anyways this is not a problem from the plugin, so I am closing this. Thanks for everthing @pc035860 !!

from angular-easyfb.

JohnBernardsson avatar JohnBernardsson commented on August 18, 2024

Oh and I also used:

// Feasible config if the FB JS SDK script is already loaded
ezfbProvider.setLoadSDKFunction(['ezfbAsyncInit', function (ezfbAsyncInit) {
    ezfbAsyncInit();
}]);

For avoid loading the sdk twice. Just leaving this written down here, in the unlikely case someone has the same exact problem 😆

from angular-easyfb.

pc035860 avatar pc035860 commented on August 18, 2024

I actually forgot that one was in README 😑
Thank you! 👍

from angular-easyfb.

JohnBernardsson avatar JohnBernardsson commented on August 18, 2024

Nah, it didn't work. I do need to load the sdk twice. ezfb is trying to initialize stuff before the "other thing" loads the SDK. I tried to make it wait until the SDK is loaded, but then after waiting for it, the angular templates are already parsed, and the "like" button doesn't show.

I'll go with this until I have time to do something else. Thanks again for the plugin!

from angular-easyfb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.