I've come across a situation similar to the one on this post. I'm having trouble getting my slick carousel to work after a successful ajax call. Despite trying all the solutions provided, it's still not functioning as expected.
The code for initializing slick:
$('.reviews-page-carousel').slick({
arrows: false,
slidesToShow: 1,
variableWidth: true,
centerPadding: '10px'
});
Ajax call section:
$.ajax({
type: "GET",
url: review_url + "?page=" + page,
success: function(result) {
$('.reviews-page-carousel').slick('unslick').slick('reinit');
}
})
An alternative approach I tried:
$.ajax({
type: "GET",
url: review_url + "?page=" + page,
success: function(result) {
$('.reviews-page-carousel').slick('unslick'); /* ONLY remove the classes and handlers added on initialize */
$('.reviews-page-carousel').slick(getSliderSettings()); /* Initialize the slick again */
}
});
Unfortunately, both methods resulted in the following error:
Uncaught TypeError: Cannot read property 'unslick' of undefined