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

Won't load data, but fires all functions #199

Closed
bran-van-d opened this issue Dec 17, 2016 · 1 comment
Closed

Won't load data, but fires all functions #199

bran-van-d opened this issue Dec 17, 2016 · 1 comment

Comments

@bran-van-d
Copy link

I looked at a past closed issue (#190), and I saw this code:

afterInfinityModel(newObjects) {
    let nextPage = newObjects.get('links.next.number');
    console.log(nextPage); //<-- make sure this works?

    this.set('nextPageToLoad', nextPage);
    this.set('_totalPages', 999999);
  },

  _buildParams() {
    let params = this._super(...arguments);
    params[this.get('pageParam')] = this.get('nextPageToLoad');
    return params;
  }

Mainly, looking at "make sure this works part... in my case, it doesn't work! It just returns and empty object. It understands that there are more items and more pages, but it doesn't make any additional requests. Here is my current route:

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

const { Route, $, get, set } = Ember;

export default Route.extend(InfinityRoute, {
  _canLoadMore: true,

  totalPagesParam: 'meta.totalPages',

  model(params) {
    params.modelPath = 'controller.records';
    return this.infinityModel('entity', params);
  },
  queryParams: {
    attributes: { refreshModel: true },
    sortField: { refreshModel: true },
    sortDirection: { refreshModel: true },
    searchString: { refreshModel: true },
    perPage: { refreshModel: true },
    startingPage: { refreshModel: true }
  },

  setupController(controller, model) {
    this._super(...arguments);
    set(controller, 'records', model);
  },

  infinityModelUpdated() {
    let controller = get(this, 'controller');

    set(controller, 'isLoading', false);
  },

  afterInfinityModel(newObjects) {
    debugger;
    let nextPage = newObjects.get('links.next.number');
    console.log(nextPage); //<-- make sure this works?

    this.set('nextPageToLoad', nextPage);
    this.set('_totalPages', 999999);
  },

  actions: {

    isLoading() {
      let controller = get(this, 'controller');
      set(controller, 'isLoading', true);

      this.send('infinityLoad');
    }
  }
});

The loading was working prior to upgrading to Ember 2.9 -- but it seems like others are loading just fine with that Ember version. Let me know what you think.

@hhff
Copy link
Collaborator

hhff commented Dec 19, 2016

Hi Brandon, guessing from your other issue this is closed. Please re-open if you need more help here.

@hhff hhff closed this as completed Dec 19, 2016
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

2 participants