Lazar Bulatovic
Lazar Bulatovic

Reputation: 169

Carousel slider autoplay after its loaded with ajax

I'm using twitters bootstrap and carousel, but I loaded slider with ajax, and autoplay doesn't work... It works if it is not loaded by ajax... Some solution??

My code:

$(function () {
    $('.carousel').carousel({
        interval: 4000
    });
})

Upvotes: 1

Views: 489

Answers (1)

Leeish
Leeish

Reputation: 5213

Without seeing the rest of your code it's hard to tell, but you need to run

$('.carousel').carousel({
    interval: 4000
});

after you load the carousel into the DOM.

So

$.ajax({
    /* */
    complete: function(){
    /*load carousel*/
    $('.carousel').carousel({
        interval: 4000
    });
});

Upvotes: 1

Related Questions