Skip to content

Instantly share code, notes, and snippets.

@colonelrascals
Created March 3, 2017 02:45
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 colonelrascals/f21a849c23db8ab58751d67e82171b4f to your computer and use it in GitHub Desktop.
Save colonelrascals/f21a849c23db8ab58751d67e82171b4f to your computer and use it in GitHub Desktop.
STUCK
//------------------------------------------------------------------------->
// Models
//------------------------------------------------------------------------->
//api_key = nj5ttz726ygmvar5bqvl1cjh
var EtsyCollection = Backbone.Collection.extend({
url: 'https://openapi.etsy.com/v2/listings/active.js',
parse: function(apiResponse) {
return apiResponse.results
}
})
//------------------------------------------------------------------------->
// View
//------------------------------------------------------------------------->
var homeView = Backbone.View.extend({
initialize: function(){
this.listenTo(this.homePage,'update',this._render)
},
_render: function(){
mainNode = document.querySelector('.main')
html += '<img src="'+ this.model[0].attributes.Images[0].url_175x135 + '">'
mainNode.innerHTML = html
}
})
//------------------------------------------------------------------------->
// Controller
//------------------------------------------------------------------------->
EtsyRouter = Backbone.Router.extend({
routes: {
"home" : "etsyHomePage",
"search/:query" : "searchPage",
"about" : "aboutPage"
},
etsyHomePage:function(){
var homeInstance = new EtsyCollection()
homeInstance.fetch({
dataType: 'jsonp',
data: {
includes:"Images",
'api_key': 'nj5ttz726ygmvar5bqvl1cjh'
}
})
new homeView({
homePage: homeInstance
})
}
}
})
new EtsyRouter()
Backbone.history.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment