i have array has over 10K records i need to paginate it , I've found a cool function but its work only in foreground
in background
i got Error undefined _
for example :
var myArray = bla.GetInfo(); //has over 10K records
var page1 = getPaginatedItems(myArray, 1 , 500 );
//this function working fine only in foreground
function getPaginatedItems(items, page , per_page ) {
var page = page || 1,
offset = (page - 1) * per_page,
paginatedItems = _.rest(items, offset).slice(0, per_page);
return { page : page,
per_page : per_page,
total : items.length,
total_pages : Math.ceil(items.length / per_page),
data : paginatedItems
};
}
i think the problem from this method _.rest
any ideas how make this function work in background ? if not dose anyone has similar function do same job ! without underscore methods ?
set a per page record here 4