当使用Jquery动态生成时,Facebook标签不会呈现 [英] Facebook tags dont render when generated dynamically using Jquery

查看:169
本文介绍了当使用Jquery动态生成时,Facebook标签不会呈现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给你一个简单的用例 - 在我的网站上,我显示Facebook用户发表的评论。对于每个评论,我使用fb:profile-pic标签和fb like按钮显示Facebook用户照片。

To give you a simple use case - on my website, I display the comments posted by the facebook users. For each comment I display the facebook users photo using the fb:profile-pic tag and a fb like button.

此页面呈现正确,一切显示正常。现在当用户想要阅读较旧的评论时,他们点击更多链接

This page renders properly and everything displays well. Now when the users want to read older comments, they click on the "More" link

使用Jquery,我提取旧的注释,并在javascript中添加内容fb:profile-pic和fb:like标签

Using Jquery, I pull the older comments and in the javascript build the content adding the fb:profile-pic and the fb:like tags

但是这些标签不显示。我们需要重新加载它吗?
感谢您的帮助

But these tags dont show up. Do we need to reload it or something. Thanks for your help

推荐答案

首先确保FBML正在使用检查器插入到DOM中。如果是这样,您需要做的就是告诉Facebook将FBML标签转换为HTML标签,以便您的浏览器可以呈现。使用Graph API,您可以调用FB.XHTML.parse http://开发人员。使用Javascript SDK的facebook.com/docs/reference/javascript/FB.XFBML.parse 。以下是我代码的一个例子:

First make sure the FBML is being inserted into the DOM with an inspector. If so, all you need to do is tell Facebook to convert the FBML tags to HTML tags so your browser can render it. With the Graph API you call FB.XHTML.parse http://developers.facebook.com/docs/reference/javascript/FB.XFBML.parse using the Javascript SDK. Here's an example from my code:

$('#list').append('<fb:name uid="4"></fb:name>');
FB.XFBML.parse(document.getElementById('list'));

这篇关于当使用Jquery动态生成时,Facebook标签不会呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆