6

Is it possible to add or remove slides in runtime using FlexSlider?

Diogo Cardoso
  • 21,637
  • 26
  • 100
  • 138
  • 2
    Need help on this subject too.. I have the same problem. My case is me having a first slide wich I want to delete after it was shown the first time. Any help would be much appreciated! I've removed the div using $('div').remove(); but now we need to update slider.slides. – Joeri Minnekeer Mar 01 '12 at 14:41

4 Answers4

15

The new version of FlexSlider 2 already supports this methods.

slider.addSlide(obj, pos) accepts two parameters, a string/jQuery object and an index. slider.removeSlide(obj) accepts one parameter, either an object to be removed, or an index.

Diogo Cardoso
  • 21,637
  • 26
  • 100
  • 138
  • 2
    But how do I access the slider object? – Zhen Jan 10 '13 at 05:16
  • With `.addSlide()` and `.removeSlide()` - you can only access the slider object within the `start` and `end` properties. – Ojame Apr 07 '13 at 23:08
  • 10
    @Zhen You can create the slider object like this: `var slider = $('.flexslider').data('flexslider');` and use it like this `slider.removeSlide(0);` – Simon27 May 08 '13 at 16:52
  • 1
    and what will be the data in object to add to flexslider? I am trying this data var obj="
  • "+"
  • " slider.addSlide(obj,index); but it is showing a blank whitespace without image. – Sajid Ahmad Feb 08 '15 at 13:34