Search code examples
jquerybindjquery-loadnivo-slider

running nivo slider from inside .load content


im loading some content into a div using .load and but im having a little trouble getting nivo slider to run as part of the loaded content. I think its somthing to do with binding but im not realy sure..

at the moment im uisng this for the .load

google.load("jquery", "1.6.2");

google.setOnLoadCallback(function() {
$("#pegasus-tile, #o-w").click(function(){
    $("#proj-content").load("projects/pegasus.html")
    });
});

and this for the nivo slider

$(window).load(function() {
$('#slider, #slider2').nivoSlider();
});

is there a simple way to get this to work ?


Solution

  • You can't intialize the slider unitl the html exists for it. To do this you need to intialize it within the success callback of ajax. You need to change your ajax load() method as follows

        $("#proj-content").load("projects/pegasus.html", function(){
                    /* new html exists here*/
                    $('#slider, #slider2').nivoSlider();
        });