Skip to content

Instantly share code, notes, and snippets.

@maclochlainn
Created September 2, 2013 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maclochlainn/6416139 to your computer and use it in GitHub Desktop.
Save maclochlainn/6416139 to your computer and use it in GitHub Desktop.
A JSON function to embed public gist files.
$(document).ready(function(){
$('.gistinclude').each(function(){
var gistLocation = $(this);
var state = 0;
$.getJSON('http://gist.github.com/'+$(this).attr('data-gistid')+'.json?callback=?'
, function(data){
gistLocation.replaceWith(data.div);
if (state == 0) {
$('head').append('<link rel="stylesheet" href="https://gist.github.com'+data.stylesheet+'" type="text/css" />');
state = 1;
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment