diff --git a/Makefile b/Makefile index 7379f98..d6133a9 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: setup store +.PHONY: setup store serve NOTANGLE= notangle NOWEAVE= noweave @@ -12,6 +12,11 @@ LIBS:= htdocs/lib/underscore.js htdocs/lib/jquery.js htdocs/lib/backbone.js all: htdocs/index.html htdocs/store.js htdocs/jsonstore.css htdocs/data/items.json @if [ ! -e "./htdocs/lib" ]; then echo "Please do 'make setup' before continuing"; fi +serve: all + $(COFFEE) ./bin/autoreload + +store: all + htdocs/lib: mkdir -p htdocs/lib diff --git a/bin/autoreload b/bin/autoreload index e5fa219..f213d2c 100755 --- a/bin/autoreload +++ b/bin/autoreload @@ -1,4 +1,4 @@ -#!/usr/bin/env coffee +#!/bin/env coffee fs = require 'fs' Inotify = require('inotify').Inotify @@ -13,7 +13,7 @@ monitor = new Inotify() reBuild = -> maker = spawn 'make', ['store'] - make.stdout.on 'data', spew + maker.stdout.on 'data', spew monitor.addWatch path: "./src/backbonestore.nw" diff --git a/src/backbonestore.nw b/src/backbonestore.nw index 65b6388..bef7945 100644 --- a/src/backbonestore.nw +++ b/src/backbonestore.nw @@ -391,7 +391,7 @@ class ProductListView extends _BaseView @collection.bind 'reset', _.bind(@render, @) render: () -> - @el.html(_.template(@template, {'products': @collection.toJSON()})) + @el.html(_.template(@template)({'products': @collection.toJSON()})) @ @ @@ -442,7 +442,6 @@ class ProductView extends _BaseView initialize: (options) -> _BaseView.prototype.initialize.apply @, [options] @itemcollection = options.itemcollection - @item = @itemcollection.getOrCreateItemForProduct @model @ %$ @@ -491,11 +490,10 @@ helps clarify what it is you're looking for. <>= update: (e) -> e.preventDefault() - @item.update parseInt(@$('.uqf').val()) + @itemcollection.update @model, parseInt(@$('.uqf').val()) updateOnEnter: (e) -> - if (e.keyCode == 13) - @update e + @update(e) if e.keyCode == 13 @ %$ @@ -504,7 +502,7 @@ The render is straightforward: <>= render: () -> - @el.html(_.template(@template, @model.toJSON())); + @el.html(_.template(@template)(@model.toJSON())); @ @ @@ -562,9 +560,10 @@ show that it did changed: <>= render: () -> - tel = @el.html _.template @template, + tel = @el.html _.template(@template)({ 'count': @collection.getTotalCount() 'cost': @collection.getTotalCost() + }) tel.animate({paddingTop: '30px'}).animate({paddingTop: '10px'}) @