Can't destroy slick - unslick function returns error

See original GitHub issue

I’m unable to destroy a slick instance. Calling $('.your-slider').unslick(); returns Uncaught TypeError: Cannot read property 'parent' of null on line 575 of slick.js. It would appear $slides is undefined. Is anyone else seeing this issue?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:59 (6 by maintainers)

github_iconTop GitHub Comments

41reactions
adamhughes86commented, Feb 12, 2015

Not sure if anyone is still looking at this but I was stuck on it for an hour. I realised I have either read the way you call methods wrong or it’s changed.

Instead of carousel.unslick(); you should use carousel.slick("unslick");

15reactions
wtrancommented, Sep 17, 2014

In my case I needed to destroy slick at a certain window size. This worked for me:

var $carousel = $('.carousel');

if (breakpoint === 'mobile') {
  if($carousel.hasClass('slick-initialized')) {
    $carousel.unslick();
  }
  $carousel.slick();
} else {
  $carousel.unslick();
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

SlickJS, unslick() remove issue - jquery - Stack Overflow
Try this: $('.your-slider').slick('unslick');.
Read more >
slick - the last carousel you'll ever need - Ken Wheeler
Hi there. I'm using slick in my vue js project. Having some troubles. When slick is cloning elements can't clone event listeners. How...
Read more >
kenwheeler/slick - Gitter
First one is, I'm using slick as a carousel for a list of card-style displays, which have an onclick event to add an...
Read more >
slick slider slick unslick Code Example - Code Grepper
('.your-slider').slick('unslick');
Read more >
https://www.aamu.edu/_resources/ldp/galleries/slic...
Add the slick-theme.css if you want default styling --> <link rel="stylesheet" ... settings: "unslick" // destroys slick }] }); ``` ### Events In...
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