mercredi 25 mai 2016

store.push not reflecting on template with ember-cli-pagination

I'm new to Ember.js and I'm trying to add an object to the store after an ajax request.

The problem is that it does not reflect on template if I use ember-cli-pagination.

If I use this.store.findAll in model, it works, but when I use this.findPaged it does not.

I'm using ember-inspector and the object appears in the store, just don't in the browser.

My code:

import Ember from 'ember';
import RouteMixin from 'ember-cli-pagination/remote/route-mixin';

export default Ember.Route.extend(RouteMixin, {
  actions: {
    create: function(email) {
      let adapter = Ember.getOwner(this).lookup('adapter:application');
      let url = adapter.buildURL('billing/delivery-files');
      let store = this.get('store');
      let modelName = 'billing/delivery-file';

      return adapter.ajax(url, 'POST', {
        email: email
      }).then(function(data) {
        var normalized = store.normalize(modelName, data.object);
        store.push(normalized);
      });
    }
  },
  model(params) {
    return this.findPaged('billing/delivery-file',params); //does not work
    // return this.store.findAll('billing/delivery-file'); //works
  }
});

Tried the solutions from this issue, and did not work at all.

What am I missing?




Aucun commentaire:

Enregistrer un commentaire