为什么FB.XFBML.parse()不会渲染我的插件? [英] Why FB.XFBML.parse() doesnt render my plugin?

查看:108
本文介绍了为什么FB.XFBML.parse()不会渲染我的插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码



<$ p $ href =javascript:void(0);>渲染我< / a>
< div id =social-facebook>< / div>

$('#render-me')点击(function(e){
e.preventDefault();

$('#social-facebook')。html(< fb:like id ='button-facebook'href ='http://www.google .com'send ='false'layout ='button_count'width ='450'show_faces ='false'>< / fb:like>);
FB.XFBML.parse(document.getElementById button-facebook'));
});

我点击,但按钮没有呈现。我在哪里错了?

解决方案

你必须在DOM中指定一个节点。
所以,你不能使用:

  FB.XFBML.parse(document.getElementById('button-facebook )); 

使用:

  FB.XFBML.parse(的document.getElementById( '社会的Facebook')); 

,它会正常工作;)


My code :

<a id="render-me" href="javascript:void(0);">Render me</a>
<div id="social-facebook"></div>​

$('#render-me').click(function (e){
    e.preventDefault();

    $('#social-facebook').html("<fb:like id='button-facebook' href='http://www.google.com' send='false' layout='button_count' width='450' show_faces='false'></fb:like>");
    FB.XFBML.parse(document.getElementById('button-facebook'));    
});

I click, but the button is not rendered. Where am I wrong?

解决方案

You have to specify a node already in DOM. So, you can't use:

FB.XFBML.parse(document.getElementById('button-facebook'));

use instead:

FB.XFBML.parse(document.getElementById('social-facebook'));

and it will work fine ;)

这篇关于为什么FB.XFBML.parse()不会渲染我的插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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