Guest User

Untitled

a guest
Jan 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. /**
  2. * Provides paged content based on a larger result set.
  3. */
  4. App.PagedArrayController = SC.ArrayProxy.extend({
  5.  
  6. content: [],
  7.  
  8. /**
  9. * Subclasses should define the allResultsBinding to bind to the full set
  10. * of results to be paged through
  11. */
  12. allResults: [],
  13.  
  14. /*
  15. * Must replace entire pagination object for changes to propogate.
  16. */
  17. pagination: {
  18. start: 0,
  19. limit: 50
  20. },
  21.  
  22. _allResultsDidChange: function() {
  23.  
  24. var results = this.get('allResults'),
  25. pagination = this.get('pagination'),
  26. lastIndex = pagination.start + pagination.limit,
  27. allResultsLength = this.get('allResults').get('length');
  28.  
  29. if(lastIndex > allResultsLength) {
  30. lastIndex = allResultsLength;
  31. }
  32.  
  33. this.set('content', results.slice(pagination.start, lastIndex));
  34.  
  35. }.observes('*allResults.[]', 'pagination')
  36.  
  37. });
Add Comment
Please, Sign In to add comment