slick icon indicating copy to clipboard operation
slick copied to clipboard

Cannot read property 'slidesToShow' of undefined

Open kyleknighted opened this issue 7 years ago • 13 comments

short description of the bug / issue, provide more detail below.

Getting Uncaught TypeError: Cannot read property 'slidesToShow' of undefined on the first click of a customPaging button, but then the slideshow works fine after that.

====================================================================

http://jsfiddle.net/kyleknighted/pofc1qmv/3/

====================================================================

Steps to reproduce the problem

  1. on load or click into any tab
  2. click any customPaging button
  3. Check your browser's Console and see the aforementioned error.
  4. Click any button again and the slide will change to the proper one

====================================================================

What is the expected behavior?

Not to have an error the first time i click a button

====================================================================

What is observed behaviour?

I'm getting an error.

====================================================================

More Details

  • Chrome Version 56.0.2924.87 (64-bit) is the only current tested version, but that's already too many browsers.
  • jquery = 1.12.4
  • Slick = 1.6.0

kyleknighted avatar Mar 28 '17 19:03 kyleknighted

Hmm I'm not getting any errors when I click on your buttons. Am I misunderstanding something?

leggomuhgreggo avatar Apr 19 '17 20:04 leggomuhgreggo

The same problem with Slick 1.6.0, But old version 1.5.6 works perfect!

AlexWaha avatar May 12 '17 23:05 AlexWaha

getting same error here

xanisu avatar Jul 19 '17 08:07 xanisu

slick.js?v=1.x:2538 Uncaught TypeError: Cannot read property 'slidesToShow' of undefined

at Slick.slideHandler (slick.js?v=1.x:2538)
at Slick.changeSlide (slick.js?v=1.x:706)
at HTMLButtonElement.f (jquery.min.js?v=2.2.4:2)
at HTMLButtonElement.dispatch (jquery.min.js?v=2.2.4:3)
at HTMLButtonElement.r.handle (jquery.min.js?v=2.2.4:3)

Slick.slideHandler @ slick.js?v=1.x:2538 Slick.changeSlide @ slick.js?v=1.x:706 f @ jquery.min.js?v=2.2.4:2 dispatch @ jquery.min.js?v=2.2.4:3 r.handle @ jquery.min.js?v=2.2.4:3`

joey91133 avatar Aug 09 '17 07:08 joey91133

If you use "asNavFor" option, be sure that you provide correct link to another slider, otherwise you get that error.

rudenich avatar Sep 28 '17 22:09 rudenich

I was seeing this error when using Ajax and leaving a page... turns out the autoplay is still trying to run after the slick container is now gone... so you get those errors... my fix was to apply: $('#your-slick-element').slick('slickPause'); when I left the page that has Slick.

Note: you might need to do this on both slick elements if you're using asNavfor

sebszocinski avatar May 19 '18 04:05 sebszocinski

the same error i have face

sumitk-monotype avatar Aug 05 '19 15:08 sumitk-monotype

If you use "asNavFor" option, be sure that you provide correct link to another slider, otherwise you get that error.

This fixed it for me

filipe-q avatar Oct 15 '19 08:10 filipe-q

If you use "asNavFor" option, be sure that you provide correct link to another slider, otherwise you get that error.

This also worked fine for me ... thanks

baffuorakoto avatar Oct 07 '21 01:10 baffuorakoto

If you use "asNavFor" option, be sure that you provide correct link to another slider, otherwise you get that error.

This worked for me! Thanks!

Matt-F-95 avatar Dec 03 '21 15:12 Matt-F-95

If you use "asNavFor" option, be sure that you provide correct link to another slider, otherwise you get that error.

Same problem, because of small 'dot'! Thanks!

yuandrian avatar Apr 22 '22 01:04 yuandrian

If you use "asNavFor" option, be sure that you provide correct link to another slider, otherwise you get that error.

Got the same error and this works for me. Thanks a million!

katrine-ren-davidjones avatar Mar 21 '23 05:03 katrine-ren-davidjones

For those using shadow dom:

const slickA = $('.slick-a', shadowRoot);
const slickB = $('.slick-b', shadowRoot);

slickA.slick({asNavFor: slickB});
slickB.slick({asNavFor: slickA});

If you use "asNavFor" option, be sure that you provide correct link to another slider, otherwise you get that error.

vivere-dally avatar Jan 16 '24 09:01 vivere-dally