0

I have the following functions in my document

jQuery(document).ready(function() {
jQuery('body').on('click', 'a.menu', function () { 
        var target = jQuery(this).attr('href');
    jQuery('#container').load(target+' #content');
        return false;
    });

$("a.group").fancybox();

});

The first one replaces the container with the href of the menu link. The corresponding subpages are actually plain divs but could be complete html (if necessary).

The second one calls a fancybox gallery on the selected elements.

How do i get this $("a.group").fancybox() to be executed, when the subpages are loaded?

Many thx in advance, mart05

Serge P
  • 1,173
  • 3
  • 25
  • 39

2 Answers2

1

You can use the complete callback feature in .loads.

jQuery('#container').load(target+' #content', function(){
    // this will run when .load has completed loading content
    $("a.group").fancybox();
});
AlexCheuk
  • 5,595
  • 6
  • 30
  • 35
1

Load has a callback function. so execute the fancybox in this:

jQuery('#container').load(target+' #content', function() {
              $("a.group").fancybox();
          });
Liam
  • 27,717
  • 28
  • 128
  • 190