How to change pagination parameters dynamically?
For example enable/disable dynamicBullets on button click.
I'm trying to change the value through: mySwiper.params.pagination.dynamicBullets = ....
And then I do: mySwiper.update(); mySwiper.pagination.update()
but it doesn't work.
Here is a small demo: https://codepen.io/abvas/pen/VwxYWae
var mySwiper = new Swiper ('.swiper-container', {
loop: true,
pagination: {
el: '.swiper-pagination',
clickable: true,
dynamicBullets: false
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
})
let btn = document.getElementById('btn');
btn.addEventListener("click", () => {
let state = mySwiper.params.pagination.dynamicBullets;
mySwiper.params.pagination.dynamicBullets = !state;
mySwiper.pagination.update()
mySwiper.update();
console.log(mySwiper.params.pagination.dynamicBullets)
})
press the "ON/OFF" button at the top.
Please tell me what am I doing wrong.
Thank you.