Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Provides paged content based on a larger result set.
- */
- App.PagedArrayController = SC.ArrayProxy.extend({
- content: [],
- /**
- * Subclasses should define the allResultsBinding to bind to the full set
- * of results to be paged through
- */
- allResults: [],
- /*
- * Must replace entire pagination object for changes to propogate.
- */
- pagination: {
- start: 0,
- limit: 50
- },
- _allResultsDidChange: function() {
- var results = this.get('allResults'),
- pagination = this.get('pagination'),
- lastIndex = pagination.start + pagination.limit,
- allResultsLength = this.get('allResults').get('length');
- if(lastIndex > allResultsLength) {
- lastIndex = allResultsLength;
- }
- this.set('content', results.slice(pagination.start, lastIndex));
- }.observes('*allResults.[]', 'pagination')
- });
Add Comment
Please, Sign In to add comment