FB.XFBML.parse() on individual element does nothing

倖福魔咒の 提交于 2019-11-30 09:05:29
Grin

The docs specifies that the dom element should be root DOM node, defaults to body. So I replace.each function call with a single call to a .parse method with the created DOM element. Here is a jsfiddle.

 FB.XFBML.parse($newhtml[0]);

Note: FB.XFBML.parse() should be called on a parent element of the widget, not directly on the XFBML element itself.

In my case the accepted solution wouldn't work, because the FB posts are appended in the same DOM container.

What i ended up doing, is run a FB.XFBML.parse() to the container, use an .each loop and removeClass the fb-post, add class facebook-post-loaded. Then on subsequent Ajax calls and fetches of new fb posts, the FB.XFBML.parse() would not pick the already loaded elements since they don't have the fb-post class anymore.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!