0

I have PHP page where users can upload photos (using Ajax & PHP script). Those uploaded photos (thumbs) are shown after upload in DIV below upload field and fancybox plugin (I'm using it for popup window for photos) is working ok then.

Then, after hitting send button I want to clone that DIV at that same page at message board, bellow other messages with or without uploaded photos.

When I try to do that with:

var pht = $("#photos").clone().addClass('p_pht');

and try to display sent photos bellow sent message like this:

$("div#wall").append('<div class=msg>'+ message +'</div><div class=n_pht>'+ pht.html() +'</div>');

Fancybox plugin don't work. Only the link is working but not with popup window as it should be.

What am I doing wrong?

Sergio
  • 1,207
  • 7
  • 28
  • 42

1 Answers1

2

because you've changed the dom the fancybox plugin doesn't know the new elements exist. there are two ways of solving this.

  1. Call the fancybox plugin again when you've finished adding elements
  2. Use jquery live as answered here jquery live & livequery

Hope that helps.

Community
  • 1
  • 1
Josh
  • 6,256
  • 2
  • 37
  • 56
  • I try with Jquery live. Still, It doesn't work:( I put this code after I added elements with append: $(' .poruka_tekst').live('click', function(){ $(this).fancybox(); }); But nothing happened. When I put this function just to test the DIV id, alert message showed up. $(' .pht').live('click', function(){ alert("link testing"); }); As I said, at bottom of the page fancybox working just fine. Can I try something different? – Sergio Feb 24 '10 at 22:39