dimanche 1 mai 2016

ember infinite scroll model with fixture data

I am trying to roll infinite scroll, found here: http://ift.tt/1p3OX9C into my app but the instructions and examples are too sparse.

This is what my route looks like before:

import Ember from 'ember';

import { users } from '../mirage/fixtures/data';

var usersRoute = Ember.Route.extend({
    model() {
        return users;
    }
});
export default usersRoute;

I'm not really sure what { users } means. It works, but I don't know how to interpret it with the infinite scroll add-on. According to its basic usage, it looks like this:

import Ember from 'ember';
import InfinityRoute from "ember-infinity/mixins/route";

export default Ember.Route.extend(InfinityRoute, {
  model() {
    /* Load pages of the Product Model, starting from page 1, in groups of 12. */
    return this.infinityModel("product", { perPage: 12, startingPage: 1 });
  }
});

So I've naively tried to blend them together, like this:

import Ember from 'ember';
import { users } from '../mirage/fixtures/data';
import InfinityRoute from "ember-infinity/mixins/route";

var usersRoute = Ember.Route.extend(InfinityRoute, {
    model() {
        return this.infinityModel("users", { perPage: 12, startingPage: 1 });
    }
});
export default usersRoute;

This gives me the error: ember.debug.js:28556 Error while processing route: users.index No model was found for 'users' Error: No model was found for 'users'

Obviously I'm not referencing users correctly. I tried removing the quotes around user but that just gives me a different error.




Aucun commentaire:

Enregistrer un commentaire