-
Notifications
You must be signed in to change notification settings - Fork 252
Feature request: Infinite mode with total records #385
Comments
I think lib will expect to have actual models aswell, so beside having links for all pages, you probably need to generate (and then update) some stub models. I believe that lib just slice models from backbone.paginator/lib/backbone.paginator.js Lines 912 to 916 in 1766e8f
Links persistent checked few lines above backbone.paginator/lib/backbone.paginator.js Line 903 in 1766e8f
I face the problem that i want reuse already fetched models, and having a paging, that means that i need to load pages from first to last sequentially, to prevent As a temporarily "fix" i have override import PageableCollection from 'backbone.paginator';
export class Foo extends PageableCollection {
getPage(index, options) {
const useServerMode = (
index > this.state.firstPage &&
this.length === 0 &&
this.mode === 'infinite'
);
if (useServerMode) {
const fetch = false; // Prevent unnecessary fetch while switching modes
this.switchMode('server', {
fetch
});
this.once('sync', function() {
this.switchMode('infinite', {
fetch
});
}, this);
}
return super.getPage(index, options)
}
} |
@ogonkov I've invited you as a collaborator of this repo. Since I don't use this library much anymore, it'd be nicer for someone who knows what's going on to help maintain it. |
@wyuenho thank you |
I have an API that returns the number of records, but not the "next", "previous" headers/response data. I want to fetch info from this API using infinite scroll.
Currently if I try to use "server" mode with total records every request will clear previous models.
If I try to use "infinite" mode I need to generate the links myself.
It'd be cool if the plugin requests next page as in "server" mode when "total_records" is available instead of looking for links in "infinite" mode.
The text was updated successfully, but these errors were encountered: