From 7663c88dba4da60afde4691fc925e2f4cf6e3c4b Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 6 Jan 2013 14:33:40 +0100 Subject: o Much better person list. --- src/main/webapp/apps/core/PagingTableService.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/main/webapp/apps/core/PagingTableService.js') diff --git a/src/main/webapp/apps/core/PagingTableService.js b/src/main/webapp/apps/core/PagingTableService.js index d65e7f3..a6a10f7 100755 --- a/src/main/webapp/apps/core/PagingTableService.js +++ b/src/main/webapp/apps/core/PagingTableService.js @@ -1,14 +1,17 @@ function PagingTableService() { - var create = function ($scope, fetchCallback) { + var create = function ($scope, fetchCallback, options) { + options = options || {}; + var watcher = options.watcher || function(){}; var self = { rows: [], - startIndex: 0, - count: 10 + startIndex: options.startIndex || 0, + count: options.count }; var update = function(){ fetchCallback(self.startIndex, self.count, function(data) { self.rows = data.rows; + watcher(); }); }; @@ -40,12 +43,16 @@ function PagingTableService() { args = args || {}; return function(startIndex, count, cb) { console.log("fetching", arguments); - args.startIndex = startIndex; - args.count = count; + if(startIndex) { + args.startIndex = startIndex; + } + if(count) { + args.count = count; + } Resource.query(args, function(data, headers) { var totalResults = headers("total-results"); - console.log("got data", arguments); console.log("totalResults", totalResults); + console.log("got data", data); cb({ totalResults: totalResults, rows: data -- cgit v1.2.3