I'm attempting to fetch data from MySQL (with a PHP-based API) using Backbone. I want to retrieve items in batches of 20 though. For example, I have 10,000 records, but only want to show 20 records upon page load. As the user scrolls down I'd like to load the next 20 every time they reach the bottom of the page. My query is not sorted by ID (by design), so that may add one level of complexity. How is this possible in Backbone?
Asked
Active
Viewed 584 times
1 Answers
3
I recommend to use this plugin https://github.com/backbone-paginator/backbone.paginator

Vitalii Petrychuk
- 14,035
- 8
- 51
- 55
-
Yeah, have been looking through this, and am connecting to my API fine, but not sure how to set the API get requests to respond to what the paginator sends over (I'm sending data over in json, not jsonp. – bentedder Jun 27 '13 at 17:51
-
This is not a problem, you can configure your query in the `paginator_core` object. Just remove `dataType: 'jsonp'` - Infinite Pagination example http://addyosmani.github.io/backbone.paginator/examples/infinite-paging/. – Vitalii Petrychuk Jun 27 '13 at 17:54
-
Thanks. But how does the paginator modify my MySQL script so it's only pulling 20 items at a time from the database? Is that how it works? Do I need to set the LIMIT in my sql statement according the query parameter? – bentedder Jun 27 '13 at 18:05
-
Oh, this is another question. I'm not a backend developer and cannot recommend you how to implement server API in that case. Please take a look at this question http://stackoverflow.com/questions/13872273/api-pagination-best-practices – Vitalii Petrychuk Jun 27 '13 at 18:11