Created
December 23, 2014 23:29
-
-
Save chris-brown/8d815606f93a483a671d to your computer and use it in GitHub Desktop.
renders handlebar template from github api data
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
(function ($j) { | |
"use strict"; | |
var app = { | |
query: 'https://api.github.com/users/chris-brown/repos', | |
containerId: '#container', | |
init: function(){ | |
this.getData(); | |
}, | |
getData: function(){ | |
$j.getJSON(this.query, $j.proxy(this.callback, this)) | |
}, | |
callback: function(data){ | |
if(data && data.length > 0){ | |
var compiledTemplate = Handlebars.templates['demo-list']; | |
$j(this.containerId).html(compiledTemplate(data)); | |
} | |
} | |
} | |
app.init(); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment