kenwheeler / slick

the last carousel you'll ever need
kenwheeler.github.io/slick
MIT License
28.49k stars 5.89k forks source link

add support for multiple asNavFor selectors #2527

Open elineopsommer opened 8 years ago

elineopsommer commented 8 years ago

When set multiple selectors on the "asNavFor" setting, there's a bug "Uncaught TypeError: Cannot read property 'getSlick' of undefined". The error occurs on this code snippet: `if (.options.asNavFor) { navTarget = .getNavTarget(); navTarget = navTarget.slick('getSlick');

    if (navTarget.slideCount <= navTarget.options.slidesToShow) {
        navTarget.setSlideClasses(_.currentSlide);
    }
}`

This is fixed by following the same approach as in " Slick.prototype.asNavFor": if (_.options.asNavFor) { navTarget = _.getNavTarget(); if (navTarget !== null && typeof navTarget === 'object') { navTarget.each(function () { var navTarget = $(this).slick('getSlick'); if (navTarget.slideCount <= navTarget.options.slidesToShow) { navTarget.setSlideClasses(_.currentSlide); } }); } }

I created a pull request to solve this issue (#2526)

leggomuhgreggo commented 7 years ago

Dope! Thanks I will try to review the PR soon.

Jeff-3dvia commented 7 years ago

I've the same problem !! :'(

but the fix don't works for me

elineopsommer commented 7 years ago

You can use the repo https://github.com/elineopsommer/slick for now till the pull request is merged. Can you let me know if this works for you?

Jeff-3dvia commented 7 years ago

Really! ? :'( :'( But at first, I copied your commit, exactly on the same line in version 1.6 of the repo. And now, I used the minified file via CDN: https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.js

And I always thus error in my file, unfortunately, I can not recurrence of jsFiddle :(

Jeff-3dvia commented 7 years ago

jsFiddle it's works : https://jsfiddle.net/y9axf5kp/1/

but not in local site

Jeff-3dvia commented 7 years ago

So, arrows no longer function, but the slider is well established, it's weird

Jeff-3dvia commented 7 years ago

I Got IT !!!!! ^^

It's Good and It's Beautiful !!!!!! lool nooooo it's an idea of my boss ^^

yanuas123 commented 5 years ago

I had the same problem on the version 1.6 I replaced it with the varsion 1.5.9 and it works.