Created
October 22, 2013 00:26
-
-
Save tstachl/7093263 to your computer and use it in GitHub Desktop.
This is an example of how you can use the desk.js pagination from the last page to the first page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get the first cases page | |
client.cases(function(err, cases) { | |
// define a worker function that handles the | |
// cases and starts over with the previous page | |
// make sure you have a "callback" (doSomethingElse) | |
// function defined before going into this loop | |
function workCases(err, cases) { | |
// test if cases is null (previous will return null | |
// if there is no previous page) | |
if (cases !== null) { | |
// run your logic on the cases | |
_.each(cases, function(case) {}); | |
// get the previous page | |
return cases.previous(workCases); | |
} | |
// don't forget to finish the process with | |
// doing something else. | |
return doSomethingElse(); | |
} | |
// start the process with the last page | |
cases.last(workCases); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment