jeudi 5 mai 2016

How is ajax pagination handled in EmberJS?

I am a fresher to EmberJS and have started developing a REST application. Currently I want to implement pagination on my listed items. I searched around a bit regarding this and can't seem to figure out the best way to to it.

Controller: I have extracted the parameters in the ember URL using queryParams. Here, I can't figure out on how to apply the changed pagination values.

export default Ember.Controller.extend({
 queryParams:['page', 'size'],
 page: 1,
 size: 1,
 action: {
   nextPage: function() {
     this.page += 1;
     //how to retrieve data here ?
   },
   previousPage: function() {
     this.pageNumber -= 1;
     //how to retrieve data here ?
   }
 }
})

Route: Following this configuration in my route, I was able to pass the pagination params in Ember URL to API URL parameters.

export default Ember.Route.extend({
  model: function(params) {
  return this.store.query('task', {
    page: params.page,
   _end: params.size
  });
 }
});

Even after searching through number of references I am still confused on how to present the pagination URL parameters into the view and how to apply the changes to pagination.

Frankly, I am a bit confused on the overall concept itself.

A little explanation regarding this would be greatly helpful.




Aucun commentaire:

Enregistrer un commentaire