Error with get ('model'). AddObjects () in Ember 1.13.0

I am updating my Ember app from 1.11 to 1.13.2

I have a blog initially displaying 5 blog posts. They are loaded into the model using this route:

import Ember from 'ember';
export default Ember.Route.extend({

  model: function() {
    return this.store.find('post', {limit: 5});
   }
});

      

There is a button to load more records into the controller:

loadMore: function() {
  var self = this
  this.store.find('post', {limit: 5,
                           skip: 5})
    .then(function(posts) {
      self.incrementProperty('page');
      self.get('model').addObjects(posts);
    });
}

      

However, since the update, I get this error after executing loadMore

:

TypeError: internalModel.getRecord is not a function
    at Ember.ArrayProxy.extend.objectAtContent (record-array.js:84)
    at _emberRuntimeSystemObject.default.extend.objectAt (ember.debug.js:35919)
    at _emberRuntimeSystemObject.default.extend.objectAtContent (ember.debug.js:35780)
    at _emberRuntimeSystemObject.default.extend.objectAt (ember.debug.js:35919)

      

+3


source to share


1 answer


You use ember-cli

, it is loaded with babel, can also use ES6 syntax, load more becomes like this:



loadMore() {
  this.store.find('post', {
    limit: 5,
    skip: 5
  })
    .then((posts) => {
      this.incrementProperty('page');
      let model = this.get('model');
      posts.forEach(model.pushObject.bind(model));
    });
}

      

+1


source







All Articles