viktorlarsson / vue-tiny-slider

Vanilla javascript slider for all purposes created by ganlanyuan in Vue.
MIT License
136 stars 51 forks source link

Is it possible to change the slides at run-time? #50

Closed CDuane closed 4 years ago

CDuane commented 4 years ago

I am implementing a filter so I would like to change the content of the slider at run-time. I understand that rebuild does not work due to a reactivity limitation in the original library, but has anyone managed to work around this? I would appreciate if any of you could share a solution.

CDuane commented 4 years ago

I managed to make it work. I used v-if to remove the slider instance and re-initialize it with the new slides array.

So what I did, when I click on a filter, I set the v-if to false, (to remove the slider instance), then I force an update to make sure with this.$forceUpdate(); and then in the next tick function I set the array of slides so that the new slider instance will be initialized again.


this.$nextTick(function () {
    // ... set new array here
});```