Search code examples
jqueryjquery-cycle2

Load JQuery cycle2 on loaded Ajax content


I'm trying to initiate JQuery cycle on external HTML content loaded in with Ajax, but this doesn't seem to work:

$(".container").load("step2.html", function() {
                $.fn.cycle.defaults.autoSelector = '.cycle-slideshow';
});

the html is as follows:

<div class="cycle-slideshow second-prize-slider" data-cycle-manual-speed="2000" data-cycle-slides="p" data-cycle-timeout=5000 >
                                         <p>Jetzt<br />mitmachen & <br />gewinnen</span></p>   
                                         <p >Täglich<br>mitspielen & <br> Gewinnchance<br> steigern!</p> 
                                    </div> 

Solution

  • Just call the cycle initializer manually in your callback:

    $(".container").load("step2.html", function() {
        $('.cycle-slideshow').cycle();
    });
    

    http://jquery.malsup.com/cycle2/api/