https://github.com/pouu69/backbone.pagercollection
we using pagination inside backbone.collection extends
https://github.com/pouu69/backbone.pagercollection
backbone extends library pagination
Last synced: 3 months ago
JSON representation
we using pagination inside backbone.collection extends
- Host: GitHub
- URL: https://github.com/pouu69/backbone.pagercollection
- Owner: pouu69
- Created: 2016-01-23T07:33:48.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-25T07:14:54.000Z (over 9 years ago)
- Last Synced: 2025-01-24T11:22:51.318Z (5 months ago)
- Topics: backbone, extends, library, pagination
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Backbone.PagerCollection
- Bakcbone pagination
- We can using colleciton for paginationi can't write english
----------------------------------------------
# Required
- API 내에 요청한 collection 에 대한 total count가 필요 하다. parse 메서드에서 API에서 주는 DATA Propertie에 맞게 수정 하면 된다.
````
parse : function(response){
this._count = response._count; // _count 를 각자에 맞게 수정
............
return response.data; // 이것 또한 자신의 API가 주는 json 구조에 맞게 바꾸어 return 해준다.
}
````# How to way
- 최초 collection.initPagination({...}) 을 수행한다.
- initPagination 파라미터는 Obecjt type으로써 다음과 같은 propertie가 있다.
* nbPerPaage : 각 페이지당 showing할 아이템 갯수
* totalPages : 총 페이지 갯수
* totalCount : collection의 총 model 갯수
* currentPage : 현재 페이지
* startPage : 시작 페이지
* paginationEnabled : 페이지네이션 가능 여부- 그 후에 3가지 방법으로 페이지 네이션을 진행한다.
````
collection.getNextPage(options){};
collection.getPrevPage(options){};
collection.getPage(pageNum, options){};// options 는 기본적인 backbone fetch save delete에서 사용했던 options들이다, ( callback 형식 )
// getNextPage, getPrevPage로 이전,다음 페이지로 이동이 가능하며,
// getPage로는 원하는 페이지번호로 이동할 수 있다.
````- 또한 이전,다음 페이지로 이동이 가능한지 에 대한 체크가 된다.
````
collection.hasNextPage();
collection.hasPrevPage();
````
- initPagination 을 통해 설정한 현재 collection의 페이지네이션 config확인 가능
````
colleciton.state // object로 설정한 config 확인 가능
````