Skip to content

Instantly share code, notes, and snippets.

@CraigCav
Created March 9, 2016 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CraigCav/e26f7bbca1939bc143c7 to your computer and use it in GitHub Desktop.
Save CraigCav/e26f7bbca1939bc143c7 to your computer and use it in GitHub Desktop.
function getAnimals() {
var dataSource = this;
var ajax = $.ajax({
type: 'GET',
url: '/my/remote/endpoint/',
data: {
limit: dataSource.pager.limit(),
startIndex: dataSource.pager.limit() * ( dataSource.pager.page() – 1 )
},
dataType: 'json'
});
return Promise.resolve(ajax).then(function(data) {
dataSource( data.rows );
dataSource.pager.totalCount( data.count );
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment