Kieran
Kieran

Reputation: 3995

Jquery Fancybox - $.post() Postback

I currently assign elements to Fancybox as follows:

$(document).ready(function(){
$(".popup").fancybox({
 'speedIn'  : 600, 
 'overlayOpacity'  : 0.7,
 'speedOut'  : 200
});

}); When I load remote content using $.post(), some of that content contains...

<a class="popup" href="#somebox">Click me</a>.

Clicking the link does nothing, probably because the document ready only gets processed once on page load. How can I 'reprocess' this so that links in the remote content open up the fancybox?

I've looked around must most of the solutions are ASP.net based. I am currently using standard PHP and jQuery.

Thanks.

Upvotes: 0

Views: 1075

Answers (1)

Harmen
Harmen

Reputation: 22438

You could set your own click event on these links, using .live():

$(".popup").live('click', function(){
  $.fancybox({
    'speedIn': 600, 
    'overlayOpacity': 0.7,
    'speedOut': 200,
    'href': $(this).attr('href')
  });
  return false;
});

Upvotes: 1

Related Questions