Ok, so I have a script to fetched images from Google’s Picasa image service via JSON. But what I wish is to display say 40 images per page. So if user has more then 40 lets say 80 for example then a pagination would be attached and ones clicked the next 40 images would be shown. If there is a way to do this with jQuery could some one tell me how? Here is the current code for grabbing images via JSON from Picasa
$(document).ready(function() {
$.getJSON("http://picasaweb.google.com/data/feed/base/user/--USERNAME--/?kind=photo&access=public&alt=json&callback=?",
function(data) {
var target = "#picasaweb-images"; // Where is it going?
for (i = 0; i <= 1000; i = i + 1) { // Loop through the 1000 most recent, [0-9]
var pic = data.feed.entry[i].media$group;
var liNumber = i + 1; // Add class to each LI (1-10)
var thumbSize = 2; // Size of thumbnail - 0=small 1=medium 2=large
$(target).append("<ul class='gallery'><li class='no-" + liNumber + "'><a title='" + pic.media$description.$t + "' rel='qpLightbox' href='getPhoto.jsp?o=" + pic.media$content[0].url + "' onClick=return false;><span></span><img src='getThumb.jsp?wl=4&w=170&h=120&url=" + pic.media$thumbnail[thumbSize].url + "' class='oi'/></a></li></ul>");
}
});
});
Ok so first things first – your <li> elements will have unique classes, which to me seems like the id attribute would be a better fit. Also, I’m not really sure why you’re giving each image it’s own unordered list, with only one list item, but if that’s really what you’re going for, go nuts.
I’ve never dealt with a pagination plug-in before, but if you want a new ‘page’ every 40 images, I would do something like this:
Style your ‘pic_page’ class however you like, and make sure to add the following:
This will hide all pages of pictures except the first page, to begin with.
Create some kind of simple navigation scheme:
And use jQuery to put it all together:
Obviously you’ll want to check for things like page 0, and add something to deal with a max page number, but I think this should get you headed in the right direction.