question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn't load data

See original GitHub issue

I’m using Ember 2.9.0 and I’m loading a list of Chat, so I don’t know how many total_pages it’s have.

The first time that renders the template/index loads the Chat list with 2 chats. But when I scroll down to, nothing is triggered to fetch the next page.

My page [number] is not sequential (1,2,3,4) but a random number (3812, 23894, 31283, 47472), maybe that’s the problem?

I am using JSONAPI and the link to the next is like this:

date: {...} // date of the model API
include: {...} // include the model API
links: {
   next: {
     number: 3812,
     limit: 2
   }
}

And my routes/chats/index is this:

import Ember from 'ember';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
import InfinityRoute from "ember-infinity/mixins/route";

const { RSVP: { Promise }, $: { ajax }, run } = Ember;

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

  perPageParam: "page[limit]",              // instead of "per_page"
  pageParam: "page[number]",              // instead of "page"

  beforeModel() {
    moment.locale('pt-br');
  },

  model(params) {
    return Ember.RSVP.hash({
      profiles: this.store.findAll('profile'),
      channels: this.store.findAll('channel'),
      channelAccounts: this.store.findAll('channel-account'),
      channelApplications: this.store.query('channel-application', { filter: { feature: 'inbox'} }).then(function(data) {
        return data
      }),

      chats: this.infinityModel("chat", { perPage: 2, startingPage: 0, modelPath: 'controller.model.chats' })
    })
  },

  infinityModelUpdated() {
    Ember.Logger.debug('updated with more items');
  },
  infinityModelLoaded(lastPageLoaded, infinityModel) {
    Ember.Logger.info('no more items to load');
  }
});

I’m loading the template/index this way:

<ul id="loadchat" class="inbox-list-items">
   {{#each model.chats as | chat index |}}
     {{list-chat chat=cha index=index selectChat='selChat'}}
   {{/each}}

   {{infinity-loader scrollable="#loadchat" infinityModel=model.chats loadingText="Loading ..." loadedText="Loaded"}}
</ul>

So I try to follow the solution with modelPath and

setupController(controller, model) {
    controller.setProperties(model);
  }

But this doesn’t work, when I use setupController my model doesn’t load data. Any solution to fix this to work without total_page? Or anything I’m doing wrong?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hhffcommented, Oct 27, 2016

cool! thankyou!

0reactions
danilovazcommented, Oct 27, 2016

You saved my life twice. Thank you 😃

Now I just need to keep it from endlessly load the same items. I have 5 items on the list when it comes on the last item its reloads again from the first item, infinitely.

But it’s working now. Thank you. As soon as I get free, I’ll see what I can help with PR’s.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why can't I load data?
When you start R in Windows, the working directory is by default the directory in which the R executible is located. # Print...
Read more >
We can't load any data - Microsoft Community
When we try to go to channels under Manage Teams accessing some channels in Teams we are getting error: "we can't load data....
Read more >
My phone suddenly doesn't load data in LTE mode, only in 3G
It sounds like you are having trouble accessing your cellular data. Here are some resources and troubleshooting steps that might help:.
Read more >
Error: Could not load data from data source. If you can correct ...
When opening an attribute table, or making changes to the values within, the following error message may be returned: Could not load data...
Read more >
Netflix says 'Could not load data' - Netflix Help Center
Netflix says 'Could not load data' ; Open the Play Store app. If you don't have it, you might need to fix an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found