"refresh" method deletes the slides when reinitialising the slider.
See original GitHub issueIssue Description
I’m responsively unslick
ing my slider and with Slick v1.8.1 I was able to $('.my-slider').slick('refresh');
to reinitialise the slider, however with this fork, it does attempt to reinitialise the slider but all the slides are removed and the .slick-track
is completely empty.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:7
Top Results From Across the Web
Clearing and adding slides / Reinitialising flexslider?
Step 1 - remove existing slides: var slider = $('.flexslider'); while (slider.data('flexslider').count > 0) slider.data('flexslider').
Read more >Add or delete slides in Keynote on Mac - Apple Support
Delete a slide In the slide navigator, click to select a slide or select multiple slides, then press Delete on your keyboard.
Read more >Add & Remove Slides - Embla Carousel
This guide demonstrates how to add or remove slides after Embla Carousel has been initialized.
Read more >Swiper API
Slides --> <div class="swiper-slide">Slide 1</div> <div ... querySelector('.swiper').swiper; // Now you can use all slider methods like swiper.slideNext(); ...
Read more >Documentation v5 - Keen-Slider
Documentation of the installation and usage of keen-slider library v5. ... class="keen-slider"> <div class="keen-slider__slide">1</div> <div ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for putting that together! I can confirm that this is an issue that seems to be present in accessible-slick, but not the original Slick library. But I haven’t been able to figure out the cause of it yet.
There haven’t been any changes made to either the
unslick
orrefresh
functionality directly, so whatever is going on seems like it must be a side effect to some unrelated changes.So far I’ve found that the
unslick
option is really just an alias for thedestroy()
method, and thedestroy()
method is already called by therefresh()
method. So in your example, when you “unslick” the carousel and try to do a refresh, the carousel gets destroyed twice. When the seconddestroy()
call is made inside the refresh method, the slides get removed from the DOM entirely. I think I’ve narrowed down the problem down to this line of code in thecleanUpRows()
method, but I understand yet what is going on. Seems like there is some hand-wavy jQuery magic going on that is making the issue really tricky to trace.I’m also seeing that the
refresh()
method is not officially documented or demonstrated in the original library’s README or docpage, so the intended purpose and proper usage is a bit unclear to me. As a short term solution, I wonder if you can get the results you want by re-initializing Slick entirely instead of trying to use therefresh
option, like the snippet below. But since I do really want this package to be a true drop-in replacement for Slick Slider, I want to resolve this issue regardless - I’m just not sure how long that’ll take.If you, or anyone else, has any ideas for what could be going on here, please let me know!
Thanks for looking into it! Yeah I just happened to stumble upon the
refresh
method when looking into how to easily reinitialise my slider after it has beenunslick
ed so it’s definitely possible how I’m using it is not intended.I’ll have a poke around myself if I find the time, cheers!