Problems prettyPhoto with AJAX and PHP
  • Hi ALL, My name is Percy from Peru, I have a problem.

    Well, My gallery es generated from a database witth AJAX, I'm using pagination for this.
    THE PROBLEM:

    I show 4 pictures but when I call others with "AJAX" prettyPhoto doesn't work
    I'm using prettyPhoto 2.5.5

    $(document).ready(function(){
    $(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_square'});
    });

    Please help me and sorry for my english is terrible.
  • Solution is:

    $(".ppt").remove();
    $(".pp_overlay").remove();
    $(".pp_pic_holder").remove();


    have fun :-)
  • Hi!

    Im having the same problem but sorry i did not get your solution. Could you please describe where to put that code? :P
  • Thank you for your answer ceda2k,
    but "i did not get your solution" too, PLEASE, can you explain where to put that code?

    this is my code with php:
  • After you load the second page of images, you have to execute the prettyPhoto javascript "$(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme:'dark_square'});" again. This will attach the prettyPhoto functionality to the new images you loaded in the page. If you didn't do that, when you clicked on the images, they will just open the larger size.


    HOWEVER, there is a small bug in prettyPhoto 2.5.5 and 2.5.6 relating to this functionality.

    If you are using 2.5.5, here is the fix:
    http://forums.no-margin-for-errors.com/comments.php?DiscussionID=211

    If you are using prettyPhoto 2.5.6, here is the fix:
    http://forums.no-margin-for-errors.com/comments.php?DiscussionID=323&page=1



    Matt.
  • Hi folks!
    I ran into the same problem, I'm calling new elements via an AJAX call..
    So, consider you've got your response from the php file with all the elements in the' xmlHttp.responseText' variable, after appending/inserting the fetched data into the '' element, place this code...

    document.getElementById('ulID').innerHTML = xmlHttp.responseText; //Modifying the elements with the new ones..
    $(".ppt").remove();
    $(".pp_overlay").remove();
    $(".pp_pic_holder").remove();
    $(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme:'light_square'}); // binding the new elements!

    Cheers! :)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!