Giter VIP home page Giter VIP logo

Comments (12)

wyuenho avatar wyuenho commented on August 17, 2024

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.

awaisilyastkxel avatar awaisilyastkxel commented on August 17, 2024

@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.

wyuenho avatar wyuenho commented on August 17, 2024

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.

awaisilyastkxel avatar awaisilyastkxel commented on August 17, 2024

@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.

wyuenho avatar wyuenho commented on August 17, 2024

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.

awaisilyastkxel avatar awaisilyastkxel commented on August 17, 2024

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.

wyuenho avatar wyuenho commented on August 17, 2024

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.

awaisilyastkxel avatar awaisilyastkxel commented on August 17, 2024

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.

wyuenho avatar wyuenho commented on August 17, 2024

parseLinks's second parameter is not an xhr. It's an options object. The options.xhr is jQuery's jqXHR.

from backbone-pageable.

awaisilyastkxel avatar awaisilyastkxel commented on August 17, 2024

@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.

wyuenho avatar wyuenho commented on August 17, 2024

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.

awaisilyastkxel avatar awaisilyastkxel commented on August 17, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.