$.fn.initFbComments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.mod-fbcomments{ | |
float:left; | |
margin:5px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://raw.github.com/SlexAxton/yepnope.js/master/yepnope.js"></script> | |
<button id="button">Boom</button> | |
<div id="root"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var src = [ | |
'<div class="mod-fbcomments"><fb:comments href="example.com" num_posts="1" width="250"></fb:comments></div>', | |
'<div class="mod-fbcomments"><fb:comments href="yahoo.com" num_posts="1" width="250"></fb:comments></div>' | |
].join(''); | |
$.fn.initFbComments = function(){ | |
var found = false; | |
this.each(function(){ | |
if( $('.mod-fbcomments', this).size() !== 0 ){ | |
found = true; | |
return; | |
} | |
}); | |
if(found){ | |
yepnope.loader.load('http://connect.facebook.net/en_US/all.js#xfbml=1') | |
} | |
return this; | |
}; | |
$(function(){ | |
var $root = $('#root'); | |
$('#button').click(function(){ | |
$root.empty().append(src).initFbComments(); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: $.fn.initFbComments | |
description: append facebook comments dynamically. http://jsfiddle.net/gh/gist/jQuery/1.6.2/1173316/ https://gist.github.com/1173316 http://developers.facebook.com/docs/reference/plugins/comments/ | |
authors: | |
- Takeshi Takatsudo | |
normalize_css: no |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment