Topic-icon facebook listener

Active Subscriptions:

None
7 years 6 months ago #60121 by fb_100000532508192
I'm running some custom javascript code that used facebook api. But the code almost always runs before the facebook library is ready. I'm assuming that jfbconnect has a listener so that any tags etc run after the facebook library has run and fb.int has been called. If so I'd like to know what the listener is so i can use it.

many thanks in advanced
The topic has been locked.
Support Specialist
7 years 6 months ago #60126 by alzander
Replied by alzander on topic facebook listener
Phil,
Nice to hear from you again! I hope all is well.

We do have a listener for the FB.init call defined in /components/com_jfbconnect/libraries/provider/facebook.php file. The way the Facebook Javascript works is that, after it's done initializing, it looks for a JS function called "fbAsyncInit" and if it's defined, will execute whatever is in there.

There's not a way to have 2 fbAsyncInit's that's really very reliable though. If you need to edit our code, I'd recommend:
* Putting all the code you need in a separate function, ideally loaded in the head of the document (so it's guaranteed to load before Facebook's JS is done loading)
* Then, update the code in facebook.php to only call your function
That way, there's minimal changes needed to our code and less a chance of something important being overwritten on an upgrade.

Let us know if that works. We can look into calling a function during initialization that can be overridden by users with their own custom stuff as well to work for your case.

I hope that helps,
Alex
The topic has been locked.