Codeinwp / Nivo-Slider-jQuery

Nivo Slider - The Most Awesome jQuery Image Slider
http://docs.themeisle.com/article/485-getting-started-with-the-nivo-slider-jquery-plugin
MIT License
1.25k stars 605 forks source link

Update slider #305

Open WolF-tmn opened 12 years ago

WolF-tmn commented 12 years ago

Hello! I need to update nivo-slider one time in n seconds. To do this it needs to first remove and then re-create, but with new images (taking from BD) If i can do it easier, tell me how.

So my question is how realize updating of slider?

I have tried make so:

$.ajax({
  url: '/func/getSlider.php',
  success: function (data) {
    $('#slider').data('nivoslider').stop();
    $('.theme-life').empty().append($('<div id="slider">').addClass('nivoSlider').hover(function () {$('.nivo-directionNav').show()}, function () {$('.nivo-directionNav').hide()}));
    var images = $('<img>').attr({src: data[0][0], alt: '###'});
    for (var i = 1; i >= data.legth; i++) images = images.add($('<img>').attr({src: data[i][0], alt: '###'}));
    $('#slider').append(images).nivoSlider();
  }
});