Slick: Pass settings via variable array

Created on 28 Jul 2016  路  2Comments  路  Source: kenwheeler/slick

This isn't really an issue, but more of a question/help.

I want to initiate the carousel on multiple pages but want to keep my JS tidy.

I'd like to pass in the settings and element in to the slick initia

e.g:

jQuery(element).slick({settings array via variable});

I've tried the following settings array but it doesn't render the carousel. It actually "breaks" the gulp lint task I have running.

var settings = [ dots: false, infinite: true, slidesToShow: 1, slidesToScroll: 1, lazyLoad: 'ondemand', ]

I've tried putting each setting in "quotes" etc and it doesn't work until I manually put the settings in as they're meant to be.

Is there something I'm missing here or is it not possible?

I've event tried doing "toString()" on the variable - didn't work.

Not A Bug Question / Support

All 2 comments

Why not just use the object?

var settings = { dots: false, infinite: true, slidesToShow: 1, slidesToScroll: 1 }

jQuery(element).slick(settings);

Exactly what I needed. I couldn't get the correct syntax for the settings variable.

It's working exactly as I need it to now, thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stephane-r picture stephane-r  路  3Comments

barzev picture barzev  路  3Comments

Libig picture Libig  路  3Comments

msavov picture msavov  路  3Comments

NozX18 picture NozX18  路  3Comments