Dexter Morgan
Dexter Morgan

Reputation: 127

PrettyPhoto dynamic content

I have a problem I cant seem to get working quite right. I am using pretty photo. I have a page of thumbnails, in some cases in excess of 50 on the page. when one of the thumbnails has about 20 large images associated with it. for example, if a thumbnail of a dog is clicked on I would like to popup prettyphoto and display about 20 photos of dogs. if a cat is clicked have it display about 20 photos of cats etc... the problem is that I cant seem to make the larger photos appear dynamically depending on what photo is clicked. when the thumbnail is clicked I want make an ajax call to get all the larger images and have them appear in the pretty photo popup. is there a way to do this? I have tried several ways without luck.. does anyone have a solution to this, would be very much appreciated. btw, I am using jquery to make the ajax call to an mvc controller..

Upvotes: 0

Views: 370

Answers (1)

Dexter Morgan
Dexter Morgan

Reputation: 127

I figured out the answer.. by calling the open function!

$.ajax({
                 type: "GET",
                 cache: false,
                 url: '<%=Url.Content("~/Home/GetPrettyPhotos")%>' + "/" + $(this).attr("tag"),
                 complete: function ($response) {
                     var rSplit = $response.responseText.split("|");
                     var api_images = new Array;
                     var api_titles = new Array;
                     var api_descriptions = new Array; 

                     for (var i = 0; i < rSplit.length - 1; i++) {
                         api_images.push(rSplit[i]);
                         api_titles.push("test title " + i);
                         api_descriptions.push("test descrption " + i);
                       }

                     $.prettyPhoto.open(api_images, api_titles, api_descriptions); 
                 }
             });

Upvotes: 0

Related Questions