Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: infinityModel.pushObjects is not a function #144

Closed
progand opened this issue Mar 10, 2016 · 7 comments
Closed

TypeError: infinityModel.pushObjects is not a function #144

progand opened this issue Mar 10, 2016 · 7 comments

Comments

@progand
Copy link

progand commented Mar 10, 2016

I use Ember 2.4.1 with ember-data 2.4.0
I have a problem when I use RSVP hash as a route model:

return Ember.RSVP.hash({
      feed: this.store.findRecord('rssfeed', params.feed_id),
      items: this.infinityModel('rssitem', {
        perPage: 5,
        startingPage: 1,
        filter: {
          feed: params.feed_id
        }
      })
    });

Initial loading works fine but I have an error on update:

ember.debug.js:32123 TypeError: infinityModel.pushObjects is not a function
    at _doUpdate (route.js:308)
    at _nextPageLoaded (route.js:329)
    at route.js:246
    at tryCatch (ember.debug.js:53542)
    at invokeCallback (ember.debug.js:53557)
    at publish (ember.debug.js:53525)
    at ember.debug.js:32081
    at Queue.invoke (ember.debug.js:333)
    at Object.Queue.flush (ember.debug.js:397)
    at Object.DeferredActionQueues.flush (ember.debug.js:205)

I can see that infinityModel.pushObjects is undefined in route.js:308:

    _doUpdate: function _doUpdate(newObjects) {
      var infinityModel = this._infinityModel();
      return infinityModel.pushObjects(newObjects.get('content'));
    },

How can I solve the problem?

@sylwiaeb
Copy link

@progand Look here #67 Basically, you need to add modelPath for items and then setupController.

@progand
Copy link
Author

progand commented Mar 10, 2016

Thanks!
It's good idea to add an example to docs.

@progand progand closed this as completed Mar 10, 2016
@sylwiaeb
Copy link

There is one.. :)

@progand
Copy link
Author

progand commented Mar 11, 2016

Ah yes. You're right.
I think it would be nice to have simple example with RSVP.hash and modelPath but its not necessary.

@JLin37
Copy link

JLin37 commented May 27, 2016

Hey guys, I know this is a closed issue, but I'm still get this error even though I have added modelPath for items and also setupController.

edit: this is some of my code and error

model(){
  return Ember.RSVP.hash({
    filterable: this.store.find('filterable', 1),

    listings: this.infinityModel('listing', { 
      perPage: 12, 
      startingPage: 0,
      modelPath: 'controller.listings'}),
  });
},

setupController(controller, model) {
  controller.set('listings', model);
},

ember.debug.js:32116 TypeError: infinityModel.pushObjects is not a function
at _doUpdate (route.js:309)
at _nextPageLoaded (route.js:330)
at route.js:247
at tryCatch (ember.debug.js:53783)
at invokeCallback (ember.debug.js:53798)
at publish (ember.debug.js:53766)
at ember.debug.js:32074
at Queue.invoke (ember.debug.js:333)
at Object.Queue.flush (ember.debug.js:397)
at Object.DeferredActionQueues.flush (ember.debug.js:205)

@hhff
Copy link
Collaborator

hhff commented May 27, 2016

try this @JasonLin37

setupController(controller, model) {
  controller.set('listings', model.listings);
},

@JLin37
Copy link

JLin37 commented May 27, 2016

@hhff Thank you so much, that worked great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants