From ebc8ec168886367067f639cf3976ca4c397ee169 Mon Sep 17 00:00:00 2001 From: Bianca M Fernandez Date: Tue, 12 Dec 2017 11:48:27 -0800 Subject: [PATCH 1/8] custom function method-- buy and sell --- src/models/quote.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/models/quote.js b/src/models/quote.js index 4fbf466..04db0aa 100644 --- a/src/models/quote.js +++ b/src/models/quote.js @@ -6,12 +6,14 @@ const Quote = Backbone.Model.extend({ price: 0.00 }, +// increase price by 1 buy() { - // Implement this function to increase the price by $1.00 + this.set('price', this.get('price') + 1.00); }, +// decrease price by 1 sell() { - // Implement this function to decrease the price by $1.00 + this.set('price', this.get('price') - 1.00); }, }); From 7d7efcbbf2eecb4da4dd597793f51e1b8e29aaed Mon Sep 17 00:00:00 2001 From: Bianca M Fernandez Date: Tue, 12 Dec 2017 12:19:53 -0800 Subject: [PATCH 2/8] Create quote view and start to flesh out --- src/views/quote_view.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/views/quote_view.js diff --git a/src/views/quote_view.js b/src/views/quote_view.js new file mode 100644 index 0000000..0f51fd7 --- /dev/null +++ b/src/views/quote_view.js @@ -0,0 +1,11 @@ +import Backbone from 'backbone'; +import Quote from '../models/quote'; + +const QuoteView = Backbone.View.extend({ + initialize(params) { + this.template = params.template, + this.listenTo(this.model, 'change', this.render) // when a model changes, it will re-render + } +}); + +export default QuoteView; From 03e981c5107b493995f82c505f51ee6b3f5da7a7 Mon Sep 17 00:00:00 2001 From: Bianca M Fernandez Date: Tue, 12 Dec 2017 12:26:45 -0800 Subject: [PATCH 3/8] event handling logic --- src/views/quote_view.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/views/quote_view.js b/src/views/quote_view.js index 0f51fd7..a7c308e 100644 --- a/src/views/quote_view.js +++ b/src/views/quote_view.js @@ -4,8 +4,28 @@ import Quote from '../models/quote'; const QuoteView = Backbone.View.extend({ initialize(params) { this.template = params.template, - this.listenTo(this.model, 'change', this.render) // when a model changes, it will re-render + this.listenTo(this.model, 'change', this.render) // when a model changes, it will re-render + }, + render() { + const compiledTemplate = this.template(this.model.toJSON()); + + this.$el.html(compiledTemplate); + + return this; + }, + events: { + 'click button.btn-buy': 'buy', + 'click button.btn-sell': 'sell', + }, + buy(event) { + console.log(event); + this.model.buy(); + }, + sell(event) { + console.log(event); + this.model.sell(); } + }); export default QuoteView; From ac7ab04d9081dec4b5d07cb6a3ed9fc98568f652 Mon Sep 17 00:00:00 2001 From: Bianca M Fernandez Date: Tue, 12 Dec 2017 17:21:52 -0800 Subject: [PATCH 4/8] Fix reference errors in app.js and added notes to get wave 1 working --- dist/index.html | 4 ++-- src/app.js | 27 ++++++++++++++++++++++++++- src/collections/quote_list.js | 2 +- src/models/simulator.js | 2 +- src/views/quote_list_view.js | 31 +++++++++++++++++++++++++++++++ src/views/quote_view.js | 2 +- 6 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 src/views/quote_list_view.js diff --git a/dist/index.html b/dist/index.html index 8a046fa..0fa8518 100644 --- a/dist/index.html +++ b/dist/index.html @@ -85,7 +85,7 @@

Order Entry Form