question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Initializing slider removes slides from DOM

See original GitHub issue

When initializing Slick Slider v1.8.0 or v1.8.1, the Slides are removed from DOM and an empty slider is generated. When using v1.7.1, the Slides are appearing as they should.

Slider HTML (pre-init):

<div class="promoslider">

    <div class="prod">
        <a href="#">
            <div class="imgContainer">
                <img class="thumb" src="#">
            </div>
            <h5>Lorem Ipsum</h5>
            <div class="priceContainer">
                Dolor sic Amet
            </div>
        </a>
    </div>

    <!-- Repeat div class="prod" to duplicate the slides -->
</div>

Slider settings and Init Call

<script>
        var sliderSettings= {
            speed : 300,
            slidesToShow : 1,
            slidesToScroll : 1,
            mobileFirst : true,
            arrows : false, // For now
            autoplay : true,
            autoplaySpeed : 2000,
            swipeToSlide: true,
            responsive : [{
                    breakpoint : 992,
                    settings: 'unslick'
            }, {
                    breakpoint : 767,
                    settings : {
                            slidesToShow : 2                        
                    }
            }, {
                    breakpoint : 767,
                    settings : {
                            slidesToShow : 2                        
                    }
            }, {
                    breakpoint : 468,
                    settings: {
                            slidesToShow : 1
                    }
            }]
        };
        $('.promoslider').slick(sliderSettings);
    </script>

Post-init Slider HTML

<div class="promoslider slick-initialized slick-slider">
    <div class="slick-list draggable">
        <div class="slick-track" style="opacity: 1; width: 0px; transform: translate3d(0px, 0px, 0px);">
        </div>
    </div>
</div>

Does anyone have an idea why Slick removes the slides from the DOM in the latest update?

Used libraries:

  • Slick-carousel 1.8.1
  • jQuery 3.3.1

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:3
  • Comments:12

github_iconTop GitHub Comments

3reactions
tbd-rsmcommented, Jun 25, 2018

This may be related to commit be0d17cc858fb30e6a4d6b28cc29860c7170040d, which seems to have changed the default behaviour of row wrappers.

The old default was to have one row without additional wrappers. The new one is to add wrappers even when only one row is needed. That change made some other code in my project break, which relied on the given element structure.

Setting the slick option rows to 0 worked as a fix for that issue. (as seen in a comment to the mentioned commit)

1reaction
sinan-evanshuntcommented, May 4, 2021

Using "slick-carousel": "~1.6" and David’s solution fixed it for me. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Slick Slider - How to Remove Specific Slides On Click
I am trying to make it work so you can remove a specific slide based on which one is clicked. <div class="slider add-remove...
Read more >
Initialization - Reveal.js
The most common reveal.js use case is to have a single presentation which ... This will undo all changes that the framework has...
Read more >
Slider Not Working !!! Trick to Handle ANY Slider - YouTube
Inner divs will be converted into slides. ... In our JS file, we are initializing slick slider or flex slider for the area...
Read more >
Swiper API
Slides --> <div class="swiper-slide">Slide 1</div> <div ... new Swiper(swiperContainer, parameters)- initialize swiper with options.
Read more >
Top 5 swiper Code Examples - Snyk
on('slideChange', function () { $('mark').removeClass('is-current-slide'); $('[data-slide="' + this.activeIndex + ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found