diff options
Diffstat (limited to 'StoneIsland/www/js/lib/products/ProductView.js')
| -rw-r--r-- | StoneIsland/www/js/lib/products/ProductView.js | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js index 76527c8b..c0a1ee79 100644 --- a/StoneIsland/www/js/lib/products/ProductView.js +++ b/StoneIsland/www/js/lib/products/ProductView.js @@ -41,7 +41,24 @@ var ProductView = View.extend({ color: null, code: null, - load: function(data){ + cache: {}, + + load: function(code, data){ + window.location.href = "#/product/" + code + data = data || app.collection.items[code] + if (code in this.cache) { + return this.populate(data, this.cache[code]) + } + sdk.product.item({ + code: code, + success: function(details){ + this.cache[code] = details + this.populate(data, details) + }.bind(this), + }) + }, + + populate: function(data, details){ var name_partz = data['ModelNames'].split(' ') var num = name_partz.shift() var title = name_partz.join(' ') @@ -50,7 +67,8 @@ var ProductView = View.extend({ var size = data['Sizes'][0] var size_label = SIZE_LOOKUP[size] var color = data['Colors'][0] - var color_label = color['Text'] + console.log(color) + var color_label = color && color['Text'] var body = "" this.item = data @@ -63,10 +81,13 @@ var ProductView = View.extend({ this.$type.html(type) this.$price.html(price) this.$size.html(size_label) - this.$color.html(color) + if (color_label) { + this.$color.show().html(color_label) + } + else { + this.$color.hide() + } this.$body.html(body) - - // TODO: fetch product from item API, get other Code10s so you can populate the gallery }, select_size: function(){ |
