Sajko43
Sajko43

Reputation: 13

Why is slick slider not unfiltering class?

My slickFilter works just fine, but slickUnfilter not working?

MY HTML:

<div class="slider-wrapper" id="wrapper">
      <div class="post" id="post1"></div>
      <div class="" id="post2"></div>
      <div class="" id="post3"></div>
      <div class="" id="post4"></div>
</div>

My code:

setInterval(function(){
    $('.slider-wrapper').slick('slickFilter', '.post'); 
},10000);

setInterval(function(){
    $('.slider-wrapper').slick('slickUnfilter');
},12000);

JSFiddle: https://jsfiddle.net/ajtwz3Lv/8/ For some reason JS fiddle is working, but my local HTML file does not.

Upvotes: 1

Views: 343

Answers (1)

Ed Lucas
Ed Lucas

Reputation: 7355

In your JSFiddle, you do not appear to be including the setInterval() functions within your $(document).ready(). If you're not doing this in your local code, the slider-wrapper may not be initialized by Slick before you attempt to add the setInterval().

Often sites like JSFiddle will wrap all of the JS code in a $(document).ready(), which would explain why it's working there.

Upvotes: 1

Related Questions