How to destroy/remove/unbind a Flexslider

后端 未结 4 1118
攒了一身酷
攒了一身酷 2021-01-02 07:21

There are a few discussions on the github page regarding the destroy method, and a couple questions on stack, but there hasn\'t been a straightforward answer or solution yet

4条回答
  •  忘掉有多难
    2021-01-02 07:50

    The destroy method never works for me.

    The only reliable solution I've found (since the current version 2.2.2) is to completely remove the flexslider element from the DOM, then reinstate it.

    Something like:

    $('.flexslider').remove();
    // re-insert clean mark-up so flexslider can reset itself properly
    $('.flexslider-container').append('
      ');

      Then I reinitialise the flexslider from scratch:

      var imglist = '
    • ...'; $('.flexslider ul.slides').html(imglist); $('.flexslider').flexslider({ ... });

      I also find this method is more reliable than adding and removing slides in order to get the slider to update itself.

    提交回复
    热议问题