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 ph开发者_JAVA技巧otos.
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?
because you've changed the dom the fancybox plugin doesn't know the new elements exist. there are two ways of solving this.
- Call the fancybox plugin again when you've finished adding elements
- Use jquery live as answered here jquery live & livequery
Hope that helps.
精彩评论