Created
August 7, 2014 13:35
-
-
Save arasatasaygin/9208acf032b8a00ee93b to your computer and use it in GitHub Desktop.
Render products
This file contains hidden or 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
| var renderSearchedProduct = function(products) { | |
| var Product = Backbone.Model.extend({}); | |
| var Products = Backbone.Collection.extend({ | |
| model: Product, | |
| initialize: function() { | |
| this.add(products); | |
| } | |
| }); | |
| PageData.productCollection = new Products(); | |
| var ProductListView = Backbone.View.extend({ | |
| el: 'ul.product-list', | |
| initialize: function() { | |
| this.render(); | |
| }, | |
| render: function() { | |
| var productResults = []; | |
| this.$el.empty(); | |
| var template = _.template($("#product-template").html()); | |
| PageData.productCollection.each(function(i) { | |
| productResults.push(template(i.toJSON())); | |
| }, this); | |
| this.$el.html(productResults.join('')); | |
| return this; | |
| } | |
| }); | |
| var productList = new ProductListView(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment