From 137e78826101a6c6f1a441c1b91ec61bf9d2ff4a Mon Sep 17 00:00:00 2001 From: "Elf M. Sternberg" Date: Fri, 15 Apr 2016 16:42:23 -0700 Subject: [PATCH] The codebase works end-to-end. Huzzah. --- src/backbonestore.nw | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/backbonestore.nw b/src/backbonestore.nw index bef7945..84dd29b 100644 --- a/src/backbonestore.nw +++ b/src/backbonestore.nw @@ -228,8 +228,7 @@ the [[.reduce()]] method, which goes through each object in the collection and runs the function, passing the results of each run to the next as the memo. -<>= -@ +<>= getTotalCount: () -> addup = (memo, obj) -> memo + obj.get 'quantity' @reduce addup, 0 @@ -388,7 +387,7 @@ class ProductListView extends _BaseView initialize: (options) -> _BaseView.prototype.initialize.apply @, [options] - @collection.bind 'reset', _.bind(@render, @) + @collection.bind 'reset', @render.bind @ render: () -> @el.html(_.template(@template)({'products': @collection.toJSON()})) @@ -490,7 +489,7 @@ helps clarify what it is you're looking for. <>= update: (e) -> e.preventDefault() - @itemcollection.update @model, parseInt(@$('.uqf').val()) + @itemcollection.updateItemForProduct @model, parseInt(@$('.uqf').val()) updateOnEnter: (e) -> @update(e) if e.keyCode == 13 @@ -544,7 +543,7 @@ class CartWidget extends Backbone.View template: $('#store_cart_template').html() initialize: () -> - @collection.bind('change', _.bind(@render, @)); + @collection.bind 'update', @render.bind @ @ %$ @@ -560,7 +559,7 @@ show that it did changed: <>= render: () -> - tel = @el.html _.template(@template)({ + tel = @$el.html _.template(@template)({ 'count': @collection.getTotalCount() 'cost': @collection.getTotalCost() })