var CollectionView = View.extend({ el: "#collection", template: $("#collection .template").html(), loaded: false, data: null, items: {}, events: { }, initialize: function(){ this.$content = this.$(".content") this.$loader = this.$(".loader") }, show: function(){ document.body.className = "collection" if (this.loaded) { return this.populate(this.data) } this.fetch() }, fetch: function(){ this.$loader.show() sdk.fetch_collection({ gallery_id: 31617, // STONE ISLAND / SUPREME success: this.populate.bind(this) }) }, populate: function(data){ this.$loader.hide() this.$content.empty() // DefaultCode10 console.log(data) data.SearchResponseFull.Results.Items.forEach(function(item){ this.items[ item['Code8'] ] = item var t = this.template.replace(/{{image}}/, sdk.image(item['DefaultCode10'])) .replace(/{{code8}}/, item['Code8']) this.$content.append(t) }.bind(this)) }, })