samedi 18 avril 2015

Facebook Social Plugins Only Loading Once Within Custom Lightbox using JQuery and .load();

I am attempting to create a lightbox effect with social links (very similar to what you get when you click a Twitter profile on the website itself) but I am hitting a wall.


The issue is that when I click the link once, it loads the external page as I want it to.


BUT when I close the box, and go to re open, it only loads a direct link, rather than the plugin.


You can see the early demo here: http://ift.tt/1IUvRdB


I am pretty much sure it is down to a fb.xfbml.parse(); issue, but I just can't get my head around it.


exchange.html



<div id="fb-btn">
<p id="fb-1">Click Here</p>
</div>

<div class="display" id="social-facebook"></div>

<style>
html, body {height: 100%;}
.display {display: none;position: fixed;top: 0;left: 0;text-align: center;background: rgba(0,0,0,1);width: 100%;height: 100%;color: white;}
</style>

<script>

$('#fb-1').click(function(){
$('.display').html('<div class="fb">Please Wait</div>');
$('.display').show();
$('.display > div').load('fb-1.html');
FB.XFBML.parse(document.getElementById('social-facebook'));
});

$('.display').click(function(){
$('.display > div').css('display','none');
$('.display').css('display','none');
});

</script>


regular fb embed coding located at fb-1.html



<div id="fb-root"></div>
<script>(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_GB/sdk.js#xfbml=1&version=v2.3&appId=209038619141340";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-page" data-href="http://ift.tt/1CXm3bx" data-width="500" data-hide-cover="false" data-show-facepile="true" data-show-posts="true"><div class="fb-xfbml-parse-ignore"><blockquote cite="http://ift.tt/1CXm3bx"><a href="http://ift.tt/1CXm3bx">Cheese Sandwiches</a></blockquote></div></div>


So if you have any ideas about how to get around this, I will be eternally grateful


Have a great day :)


Aucun commentaire:

Enregistrer un commentaire