D
D
damarkuzz2021-12-31 14:38:30
JavaScript
damarkuzz, 2021-12-31 14:38:30

How to activate Swiper Slider on dynamically loaded HTML?

How to activate Swiper Slider on dynamically loaded HTML that is loaded via AJAX after form submission?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Sharomet, 2021-12-31
@sharomet

If I understood correctly

// Инициализируем слайдер
let swiper = new Swiper('.worksSlider', {
  loop: true,
  observer: true,
  observeParents: true
})

// $.ajax { ....
// Получаем данные с сервера и добавляем их в слайдер
// imgPath - данные с сервера, могут быть любые
swiper.appendSlide('<div class="swiper-slide"><img src="' + imgPath + '" alt=""></div>')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question