I’m using a lightbox for image viewing and I just have to use rel="lightbox" inside <a>. The problem is that my site has AJAX for every link, so I coded:
$('a').live('click', function() {
$('#content').load($(this).attr('href'));
return false;
});
This way, every link turns to be an AJAX request. What is pissing me off is that when I don’t make any request, the lightbox works properly, but as soon as I click in a link to make the AJAX request and then click in an image, the lightbox doesn’t work.
I know that the problem is the Lightbox which isn’t adding the click event once another request is done. It happens when I use $('a').click() instead of $('a').live()
But I don’t know how to fix. Maybe I have to change the lightbox for one which adds click events?
Help!
I just changed the lightbox to Top Up lightbox and it worked perfectly. Probably, the older one wouldn’t create event listeners using
.live()‘because of AJAX calls.