zzlalani
zzlalani

Reputation: 24354

jquery client side paging on an associative multidimensional array

I'm coding a job portal where I have to bring data from an api. I need to load 1000 of jobs from this site every time. To make the system effective I have loaded 9 jobs for the first time when page loaded and then load the other remaining jobs and these 9 jobs in a java-script array via ajax (jQuery) call.

What I need to do is to apply the paging on the array and maintain the first loaded 9 jobs (since they will be first 9 in the array of 1000 jobs) on the first page. I hope this makes sense.

PS: I'm showing jobs in divs.

Thanks in advance.

Upvotes: 0

Views: 760

Answers (2)

Alex Ball
Alex Ball

Reputation: 4474

If you want to (pseudo) paginate via JQuery the results in page this could you help:

JSFIDDLE

Upvotes: 1

nunespascal
nunespascal

Reputation: 17724

Store the jobs data in a jobs array. Then you can always pick the elements to show depending on what the page the user selects.

It would be as simple as

var startIndex = selectedPage * PageSize;
var endIndex = startIndex  + PageSize;

An array of objects should be perfect for the job.

Upvotes: 2

Related Questions