Created
March 3, 2017 02:45
-
-
Save colonelrascals/f21a849c23db8ab58751d67e82171b4f to your computer and use it in GitHub Desktop.
STUCK
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
//-------------------------------------------------------------------------> | |
// 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