views:

1463

answers:

2

I am going to use the Galleriffic jquery plugin to display my images (please look at demo here: http://www.twospy.com/galleriffic/advanced.html

I want to include categories above the gallery, but when each category is clicked I want the image gallery to change dynamically. That meaning, I don't want the page to reload each time a category is clicked, rather I want just the gallery area to change. Is there any suggestions for how to approach this? AJAX perhaps? Any similar code that you have used?

+1  A: 

AJAX would work. Simply have a method that returns the HTML for that particular gallery DIV or the set of thumbs/images that make up the gallery. It's probably easier to create a server-side method to produce the gallery HTML in the first place and just reuse it to generate the HTML for the AJAX call. Have the method that obtains the new HTML re-invoke the gallery plugin on the HTML when the callback completes.

$('#category').change( function() {
    $('div#gallery').load( '/some/url/togeneratehtml',
                           { category : $(this).val() },
                           function() {
                             $('div#gallery').gallerific();
                           });
});
tvanfosson
Yes- this is very close to what I am looking for. What is this: /application/gallery.php? I am new to using javascript, so you may have to dumb it down for me. This is how I perceive your answer:When the div "#category" is clicked, the div "gallery" dynamically changes without the entire html reloading. If I place this script in the header, I will achieve my results. Is that correct?
That's a placeholder for the server-side url. It should create the HTML for the gallery div. Check out the documentation for the load function: http://docs.jquery.com/Ajax/load#urldatacallback
tvanfosson
Ah I see. I am having trouble finding the PHP function or URL that generates the gallery. It seems like the gallery is generated client side, so how would I implement your code using a server side URL? THank you so much for all your help
A: 

Nice info. Thanks, Junaid