Skip to content

Instantly share code, notes, and snippets.

@marti1125
Last active December 17, 2015 18:39
Show Gist options
  • Save marti1125/5654364 to your computer and use it in GitHub Desktop.
Save marti1125/5654364 to your computer and use it in GitHub Desktop.
badges
Zepto(function($){
var Badge = Backbone.Model.extend({});
var BadgeList = Backbone.Collection.extend({
model: Badge,
url: 'https://coderwall.com/marti1125.json?callback=?',
parse: function(response) {
return response.results;
}
});
var badgeView = Backbone.View.extend({
initialize: function(){
},
render: function(){
var html = _.template( $("#badgeTemplate").html(), {results: this.model.toJSON()} );
this.$el.html( html );
return this;
}
});
var badges = new BadgeList();
var badgesView = new badgeView({model: badges});
badges.bind('reset', function() {
$("#badges").append(badgesView.render().$el);
});
badges.fetch();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment