Permalink
Browse files

step-5 api integration

  • Loading branch information...
204NoContent committed Apr 9, 2014
1 parent 7446c0f commit 89bad0b234c87f521154034b55376906d95b7690
@@ -1,6 +1,8 @@
PhonesCollection = Backbone.Collection.extend({
model: Phone,
url: '/api/phones',
query: function (query) {
if (!query || query === '') return this.models;
return this.filter(function (phone) {
@@ -4,7 +4,7 @@ PhonesIndexListView = Backbone.View.extend({
this.filtered_collection = new PhonesCollection();
this.listenTo(this.filtered_collection, 'add', this.renderPhone);
this.render();
this.listenTo(this.collection, 'sync', this.render);
this.listenTo(this.model, 'change:sortBy', this.rerender);
this.listenTo(this.model, 'change:query', this.render);
@@ -2,17 +2,7 @@ PhonesIndexView = Backbone.View.extend({
initialize: function () {
this.filter = new Filter();
this.collection = new PhonesCollection([
{'name': 'Nexus S',
'snippet': 'Fast just got faster with Nexus S.',
'age': 1},
{'name': 'Motorola XOOM™ with Wi-Fi',
'snippet': 'The Next, Next Generation tablet.',
'age': 2},
{'name': 'MOTOROLA XOOM™',
'snippet': 'The Next, Next Generation tablet.',
'age': 3}
]);
this.collection = new PhonesCollection();
this.render();
@@ -27,6 +17,8 @@ PhonesIndexView = Backbone.View.extend({
model: this.filter,
collection: this.collection
});
this.collection.fetch();
},
render: function () {

0 comments on commit 89bad0b

Please sign in to comment.