1

I have a GWT app and Im trying to put fb social plugin comment in side of my page. However I have the folowing problem.

If I put the tag in my .html it works perfect, but If I put id dynamically (like with an HTML widjet), It does not work. It just does not display anything.

Can anyone help me? Im having this problem in general, not only with the fb:comment tag.

Note: If I use the iframe implementation of, for example, "fb:like", it works perfect.

fernandohur
  • 7,014
  • 11
  • 48
  • 86
  • Well, I finally found a very reasonable way of doing this. In GWT for every widget there is a `onLoad()` overridable method. So I just did the following: I created a `HTML html = new HTML("")` and in the onLoad method I called `FB.XFBML.parse()` – fernandohur Oct 15 '11 at 00:00

1 Answers1

2

My understanding of facebook's api is that it loads your content, and parses out the tags in the fb namespace, replacing them before the actual content is drawn for the user. In contrast, none of the GWT compiled code (or indeed any Javascript code) gets a chance to make changes to the dom until the page has loaded in the browser fully, after facebook has made the changes it needs to.

My advice: Put the fb namespaced tags on the initial page, but perhaps wrap them in a div and mark them as display:none. Then you can grab them from your GWT code and wrap them up in a widget, only to be displayed when you are ready.

Colin Alworth
  • 17,801
  • 2
  • 26
  • 39
  • Okey, but that would mean that I can only have one fb:comments tag. What happens if I want to make fb:comments tag on each of my sub-pages, like for example in a blog or in youtube, where people can comment on the specific content. Thats what I want to do, I want to put dynamic content and have a fb:comment so users can comment on the dynamic content displayed. Any tips? – fernandohur Oct 02 '11 at 17:16
  • The answer at http://stackoverflow.com/questions/5317724/inserting-fbcomments-with-javascript seems to suggest that you _can_ use the `` tag, and then run a command to get it to render the fb tag. I would look further into the api, and see if there is a way to do this without the intermediate step of adding the fb tag to the page. – Colin Alworth Oct 02 '11 at 17:56