Comments (12)
http://backbone-paginator.github.io/backbone-pageable/api/#!/api/Backbone.PageableCollection
You just need to return an object with a next link like this {next: '...'}
from backbone-pageable.
@wyuenho thank you so much for quick response, i have been banging my head from last 4 5 hours. @wyuenho i have updated my question and added the my collection code, will please tell me what mistake i am doing.
from backbone-pageable.
The links must be a URL, not an HTML anchor fragment. You must also construct the links object using the data from the resp
object, which is what your server will pass down. You can pass down JSON from the server, as long as it contains the information needed to construct the links and data.
from backbone-pageable.
@wyuenho i have tried with URL also but still it gives the same error Uncaught RangeError: No link found for page 2
from backbone-pageable.
That's because you need to return a new link for every page you fetch. parseLinks
gets called on every fetch.
Also, I'm not sure CoffeeScript's class syntax is compatible with Backbone's extend. You might just want to use Backbone.PageableCollection.extend instead.
from backbone-pageable.
Hey @wyuenho I have gone through documentation of parseLink
http://backbone-paginator.github.io/backbone-pageable/api/#!/api/Backbone.PageableCollection-method-parseLinks
it is sayint that it returns an Object, what kind of object does it needs to be return, or what would be the format of Object.
Moreoever you are saying i need to return a new link for everypage I fetch. I am just calling it 2 times, as follow
collection = ChozAdmin.Collections.Accounts()
collection.getFirstPage() # till here everything works OK
collection.getNextPage() # here it gives me the error
# OR if i do
collection.getPage(2) # still it gives me the error
from backbone-pageable.
The format of the object is just what the document says:
{ "next": "http://...", "first": "http://...", "last": "http://..." }
first
and last
are optional. Return {}
when there's no more links.
parseLinks
is called when the results come back from the server after you've fetched, so if you've called getFirstPage
, as your pages are 0-indexed, parseLinks
should return {next: "http://... url for page 1..."}
, and then when you call getNextPage
, parseLinks
should return {next: "http:// ... url for page 2..."}
. Does that make sense? Return an empty object when there are no more pages. Use the resp
parameters, which is the data coming back from the server to determine how to construct the links on the client-side.
from backbone-pageable.
Thank you so much @wyuenho, now everything is working fine, i am fetching the collection and appending in the view, the only issue i am left with is, its still giving me the same error,
Uncaught RangeError: No link found for page 4
Uncaught RangeError: No link found for page 5
Uncaught RangeError: No link found for page 6
while the data fetching and showing perfectly in browser. Also this time my URL is dynamic as follow,
{ next: "http://localhost:3000/api/accounts?to=#{xhr.to}" }
from backbone-pageable.
parseLinks
's second parameter is not an xhr
. It's an options
object. The options.xhr
is jQuery's jqXHR
.
from backbone-pageable.
@wyuenho thank you so much for helping, @wyuenho that's just a variable name, the url i m create is dynamic, moreover if I return
{ }
from parseLink
method, still it gives the same error,
Uncaught RangeError: No link found for page 2
from backbone-pageable.
If you return an empty object you are suppose to get an error. How else do I signal the end of infinite paging?
Your xhr.to
is the to
number pageable passed to the options object when you paginate. By the time parseLinks
is called, you've already reached the page to
and processing the metadata and the records.
Which version of backbone-pageable are you using anyway?
from backbone-pageable.
@wyuenho I am using latest version Version 1.4.5
, @wyuenho I believe it my stupidness 👎 for me, I still have the same error :(.
Will you please elaborate how can i detect the end of page ? Or what would be the format of hash that parseLink has to return when last page is shown ? Another question is, does getNextPage()
make another call to server when final page is show ?
from backbone-pageable.
Related Issues (20)
- `totalRecords` must be a finite integer HOT 9
- Pageable breaks when cloning collection HOT 15
- A bit tedious to prepare two sets of meta for server mode and infinite mode HOT 10
- Little concern about getLastPage() in server mode HOT 2
- Returning to same point in infinite when going back HOT 1
- getPage doesn't set correctly currentPage in client mode HOT 1
- infinite collection / fullcollection is confusing HOT 14
- Relationship between parseLinks and queryParams in infinite mode HOT 1
- Suggestion: infinite mode reset method HOT 6
- Uncaught RangeError: `currentPage` must be firstPage <= currentPage >= totalPages if 0-based. Got 7. HOT 10
- Support for 'pagesInRange' which is currently supported in Paginator. HOT 3
- Problematic line in combination with uglifier... HOT 3
- Setting order to null in queryParams sends null=desc or null=asc to server HOT 3
- Removing all items on a page does not change the page HOT 1
- Switching automatically between modes (Infinite to server mode)
- Get Method for getting individual queryParams value
- Weird behaviour with pageable on filtering
- Paginating with getNextPage() without Backgrid client mode
- In client mode, collection add will trigger remove event. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backbone-pageable.