Slick: How do I get the count of slides in the slider?

Created on 27 Apr 2017  路  5Comments  路  Source: kenwheeler/slick

I want to "sync" the slider based on some passed date. For example: I have slides with identifier 1, 2, 5. So I add <div id="slide-id-1">...</div> respectively for every ID.

Now, I get some other data: 1, 2, 4. So I have to remove slide with ID 5. My first thought is to iterate through every slide based on their index and then call slick('removeSlide' index). However, I can't find in the docs a method to get the count of slides.

How can I get this?

Most helpful comment

I'm also very interested in this.

All 5 comments

I'm also very interested in this.

Couldn't seem to get this either. Assuming by the number of issues/PR's not sure if even adding this to the API is worth it

Frustratingly, this appears to have been a method in the past but was removed somewhere along the line - https://github.com/kenwheeler/slick/issues/1219

Not sure if this is exactly what you're after, but I can get the number of slides like this:

$(".mySlider").on("init", function (event, slick) {
            var numSlides = slick.slideCount;
            console.log(numSlides);
        });

Not sure if this is exactly what you're after, but I can get the number of slides like this:

$(".mySlider").on("init", function (event, slick) {
            var numSlides = slick.slideCount;
            console.log(numSlides);
        });

Thanks for property name slideCount. Now I can get the number of slides with this.

$('#slick').slick('getSlick').slideCount
Was this page helpful?
0 / 5 - 0 ratings