I am using Easy FancyBox (a WordPress plugin version of the jQuery FancyBox plugin), which works fine until content is loaded via AJAX. I am using the following code to load a div in response to a click event:
$('.jspPane').empty().load(href + ' #load-content');
I have tried to reinitialize FancyBox as a callback, like so:
$('.jspPane').empty().load(href + ' #load-content', function(){
$('a[rel="gallery1"]').fancybox();
});
But it doesn't work. Does anyone have experience with this kind of thing?
If it's any help, here's a link to the site I'm creating: http://ecbiz119.inmotionhosting.com/~fullbo6/ The elements that should display in a FancyBox are loaded when you click the "photos" nav link.
Thanks in advance!
FOLLOW-UP:
After attempting to use the .on() method to bind fancybox, I'm still having no luck. In case it's any help, here is all of the jQuery code from my scripts file:
jQuery(document).ready(function ($) {
$('#load-content').on('focusin', function () {
$('a.photos-thumb').fancybox();
});
$('#main-nav .page-item-6 a').addClass('active');
$('#page-content').jScrollPane({
autoReinitialise: true
});
$('#page-content-container, #buy-stuff').hide();
$('#main-nav').not('.page-item-6').find('a').on('click', function (e) {
e.preventDefault();
var href = $(this).attr('href');
$('#main-nav a').removeClass('active');
$(this).addClass('active');
$('#slide-show-container, #updates-wrap .container').hide();
$('.jspPane').empty().load(href + ' #load-content');
$('#page-content-container, #buy-stuff').show();
});
$('#main-nav .page-item-6').find('a').on('click', function (e) {
e.preventDefault();
var href = $(this).attr('href');
$('#main-nav a').removeClass('active');
$(this).addClass('active');
$('#slide-show-container, #updates-wrap .container').show();
$('#page-content-container, #buy-stuff').hide();
});
});