I initialize a Swiper, but something goes wrong when I navigate to another identical page (structurally)
Initialization
var swiper = app.swiper.create('.main-swiper', {
speed: 400,
spaceBetween: 100,
observer: true //Important to check DOM changes caused by .html() or .append()
});
On Slide change event:
//On Slide Change
swiper.on('slideChange', function (e) {
var current_index = e.activeIndex; //From 0
//Remove "active" class from all swipe indicators
$('.swipe_indicator').removeClass('active');
//Insert "active" class on current item
$('.swipe-indicator-'+current_index).addClass('active');
//Bind event again, but now, looking for current_index to go to the right photo
$('.carousel-inner').on('click', function () {
myPhotoBrowserStandalone.open(current_index);
});
});
Everything goes right on the first page. But if I click to go to the second…
Uncaught (in promise) TypeError: swiper.on is not a function
I appreciate any help