javascript - Getting Facebook Like button (generated by JS) to appear -


i'm using prettyphoto lightbox image gallery. when image pops up, twitter , facebook buttons appear under it. that's built prettyphoto plugin, , works fine.

the problem is, facebook button iframe kind (which doesn't allow user enter comment). want replace html5 button (which opens comment box when click it, instead of liking).

i want replace (standard fb code iframe button):

<div class="facebook"><iframe src="//www.facebook.com/plugins/like.php?locale=en_us&href='+pp_real_links[set_position]+'&amp;layout=button_count&amp;show_faces=true&amp;width=500&amp;action=like&amp;font&amp;colorscheme=light&amp;height=23" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:23px;" allowtransparency="true"></iframe></div>

...with (standard fb code html5 button):

<div class="fb-like" data-href="instagram.com/the-pic" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false">test text</div>

when replacement, doesn't show in lightbox. works anywhere else on site though.

and yes, replaced prettyphoto css code .facebook .fb-like. put text in div verify it's showing in right place.

i think root of problem social link code defined in js; in prettyphoto settings, there's attribute called 'markup' stores html lightbox , share buttons. it's not connecting fb js code.

what's solution?

the code posted (the old iframe one) not require use of facebook javascript sdk since loads iframe.

on other hand, html5 code want use need sdk render it, see fb-like div container in sdk inserts new iframe.

from code can't if loading js sdk, if not load/init described in documentation, sure include xfbml attribute:

fb.init({     appid      : 'your_app_id', // app id     channelurl : '//www.your_domain.com/channel.html', // channel file     status     : true, // check login status     cookie     : true, // enable cookies allow server access session     xfbml      : true  // parse xfbml }); 

if using js sdk should work, unless button code added dynamically after sdk has finished loading , initializing.
if that's case use fb.xfbml.parse method:

fb.xfbml.parse();  // or can pass container element: fb.xfbml.parse(document.getelementbyid(element_id)); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -