PDA

View Full Version : help with asynch/delayed loading of FB plugin mod on showthread pages


edgeless
01-30-2015, 05:33 PM
I've been using a modified jQuery slider with an iframe feed to display our FB fan page activity. I'm using it on a vB 4.2.x installation. The code is currently in my footer template. I began to notice that about 5% of the time on showthread pages, the plugin won't finish loading and will thus cause the page itself not to reach load completion. Granted, 5% of the time isn't much... but it's still not right.

I tried adding the following string to the FB-supplied JS code block, but it made no difference:

js.async=true;


I then added the following delayed loading directive, and it worked everywhere but on showthread pages:

var myTimer = window.setTimeout(function() {
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=XXXXXXXXXXXXXXXX&version=v2.0";
}, 3000);


I can vary the 3 second time to any delay I wish and it works perfectly - everywhere except on any showthread pages! It seems that showthread just ignores this delay code. As a result, sometimes thread pages will not reach a loading completion state.

Can anyone either shed some light on why this happens, or perhaps provide a solution for me?

Thanks in advance.

Dave
01-30-2015, 05:43 PM
You use jQuery? What if you wrap all JavaScript within:

$(function(){
// All of the JavaScript here.
});

That will execute when the page has fully loaded.
We might need a link to your forum with a test account in order to debug the issue.

kh99
01-30-2015, 05:45 PM
Did you check the browser's console to see if you're getting any js errors in showthread.php?

edgeless
01-30-2015, 06:30 PM
You use jQuery? What if you wrap all JavaScript within:

$(function(){
// All of the JavaScript here.
});

That will execute when the page has fully loaded.
We might need a link to your forum with a test account in order to debug the issue.Thanks for the reply. But that seems to make no difference on the showthread pages. The entire FB iframe is still visibly loaded before the showthread page is finished refreshing.

--------------- Added 1422649905 at 1422649905 ---------------

Did you check the browser's console to see if you're getting any js errors in showthread.php?Yes I have been watching that. There have been no errors present in the console.

--------------- Added 1422662432 at 1422662432 ---------------

So... anyone know how to get showthread to parse and apply the following timer directive? (which works fine on all non showthread pages.)

var myTimer = window.setTimeout(function() {
// JS thing to do
}, 3000);



I tried the code in the header template and it won't work from there either. Why won't showthread simply make all of the function calls from the footer or header templates global? It would sure solve my problem if it did.