Skip to content

Instantly share code, notes, and snippets.

@betobaz
Forked from anonymous/getRecordsRecursive.js
Last active August 29, 2015 14:24
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 betobaz/0eb87158bacd1a65414d to your computer and use it in GitHub Desktop.
Save betobaz/0eb87158bacd1a65414d to your computer and use it in GitHub Desktop.
({
getRecordsRecursive: function(moduleName, filters, offset, collectionBuffer, callback){
var self = this;
if(offset > -1){
var collection = App.data.createBeanCollection(moduleName);
var req = collection.fetch({"filter": filters, "offset": offset});
req.xhr.success(function(data){
if(data.records){
collectionBuffer.add(data.records);
self.getRecordsRecursive(moduleName, filters, data.offset, collectionBuffer, callback);
}
});
}
else{
callback(collectionBuffer);
}
}
})
@betobaz
Copy link
Author

betobaz commented Jul 11, 2015

Función recursiva para obtener los elementos listados mediante una collection, ya que por el api se van obteniendo por bloques

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment