The codebase works end-to-end. Huzzah.
This commit is contained in:
parent
7033753dc7
commit
137e788261
|
@ -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
|
collection and runs the function, passing the results of each run to the
|
||||||
next as the memo.
|
next as the memo.
|
||||||
|
|
||||||
<<cart cart collection>>=
|
<<cart collection>>=
|
||||||
@
|
|
||||||
getTotalCount: () ->
|
getTotalCount: () ->
|
||||||
addup = (memo, obj) -> memo + obj.get 'quantity'
|
addup = (memo, obj) -> memo + obj.get 'quantity'
|
||||||
@reduce addup, 0
|
@reduce addup, 0
|
||||||
|
@ -388,7 +387,7 @@ class ProductListView extends _BaseView
|
||||||
|
|
||||||
initialize: (options) ->
|
initialize: (options) ->
|
||||||
_BaseView.prototype.initialize.apply @, [options]
|
_BaseView.prototype.initialize.apply @, [options]
|
||||||
@collection.bind 'reset', _.bind(@render, @)
|
@collection.bind 'reset', @render.bind @
|
||||||
|
|
||||||
render: () ->
|
render: () ->
|
||||||
@el.html(_.template(@template)({'products': @collection.toJSON()}))
|
@el.html(_.template(@template)({'products': @collection.toJSON()}))
|
||||||
|
@ -490,7 +489,7 @@ helps clarify what it is you're looking for.
|
||||||
<<product detail view>>=
|
<<product detail view>>=
|
||||||
update: (e) ->
|
update: (e) ->
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@itemcollection.update @model, parseInt(@$('.uqf').val())
|
@itemcollection.updateItemForProduct @model, parseInt(@$('.uqf').val())
|
||||||
|
|
||||||
updateOnEnter: (e) ->
|
updateOnEnter: (e) ->
|
||||||
@update(e) if e.keyCode == 13
|
@update(e) if e.keyCode == 13
|
||||||
|
@ -544,7 +543,7 @@ class CartWidget extends Backbone.View
|
||||||
template: $('#store_cart_template').html()
|
template: $('#store_cart_template').html()
|
||||||
|
|
||||||
initialize: () ->
|
initialize: () ->
|
||||||
@collection.bind('change', _.bind(@render, @));
|
@collection.bind 'update', @render.bind @
|
||||||
|
|
||||||
@
|
@
|
||||||
%$
|
%$
|
||||||
|
@ -560,7 +559,7 @@ show that it did changed:
|
||||||
|
|
||||||
<<cart widget>>=
|
<<cart widget>>=
|
||||||
render: () ->
|
render: () ->
|
||||||
tel = @el.html _.template(@template)({
|
tel = @$el.html _.template(@template)({
|
||||||
'count': @collection.getTotalCount()
|
'count': @collection.getTotalCount()
|
||||||
'cost': @collection.getTotalCost()
|
'cost': @collection.getTotalCost()
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue