summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-11-30 11:05:54 -0700
committermo khan <mo@mokhan.ca>2014-11-30 11:05:54 -0700
commit83d0dfcd65c08d3ce0b23064bb833545309f1e19 (patch)
tree8fa5d9c68f23b1f9ab2d1045df2163d4db85ee70
parent8039765f9d45fd5c3cbd6d6bdca01b2d748693cb (diff)
extract method to display a specific page of results and use query params to change url.
-rw-r--r--app/controllers/cakes/index.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/app/controllers/cakes/index.js b/app/controllers/cakes/index.js
index c1b2c53..66e1304 100644
--- a/app/controllers/cakes/index.js
+++ b/app/controllers/cakes/index.js
@@ -2,14 +2,19 @@ import Ember from 'ember';
export default Ember.ArrayController.extend({
page: 1,
- perPage: 18,
+ per_page: 18,
+ queryParams: ['page', 'per_page'],
actions: {
more: function(){
- this.set('perPage', this.get('perPage') + 18);
- var that = this;
- this.store.find('cake', { page: 1, per_page: this.get('perPage') }).then(function(cakes){
- that.set('content', cakes);
- });
+ //this.incrementProperty('page');
+ this.incrementProperty('per_page', 18);
+ this.displayPage(this.get('page'), this.get('per_page'));
},
},
+ displayPage: function(page, perPage){
+ var that = this;
+ this.store.find('cake', { page: page, per_page: perPage }).then(function(cakes){
+ that.set('content', cakes);
+ });
+ }
});