Swiper: Not working on class 'swiper-slide' when use slider on Modal Bootstrap

Created on 22 Aug 2015  路  9Comments  路  Source: nolimits4web/swiper

Hi as same title. I try another and it not working slide when i call modal. BUT i resize window it working.
Can you help me fix this issue. Thanks

All 9 comments

It is issue with bootstrap. Call swiper's .update method when this modal becomes visible

Hi
After the modal show i was add code but it until not working

$.getScript("/public/packages/swiper/swiper.min.js").done(function() {

    var mySwiper = new Swiper('.swiper-container', {
        pagination: '.swiper-pagination',
        paginationClickable: true,
        nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev',
        // Enable debugger
        debugger: false
    });

    mySwiper.update();

});

It is hard to say what is not working like that. Will be good to see live example with issue

Yes. It's for catch event show of Modal Bootstrap. It's working now.
That's cool. Thanks.

I have the same issue. These codes fixed it for me.
I think, Swiper not regconize swiper-slide before it shown. So we have to wait it for complete 'shown'
(Example on coffescript)

$('body').on 'shown.bs.modal', '#bootstrap-modal-element', ->
  newSwiper = new Swiper('.swiper-container',
    slidesPerView: 'auto'
    ....

@1Rhino
Yes, it's jquery event. we must recall them to work on all DOM when the page not reload.
Nice to meet you, brother!

this is how i fixed it:

//swiper 
 window.swiper = new Swiper('.swiper-container', {
    nextButton: '.swiper-button-next',
    prevButton: '.swiper-button-prev',
    pagination: '.swiper-pagination',
    paginationType: 'progress'
});

i am using it on material design.
i hope it will help.
Cheers.

And this is how I fixed.

setTimeout(function() {

    var swiper = new Swiper(".swiper-container", {
        loop: true,
        autoplay: 10000,
        grabCursor: true,
        centeredSlides: true,
        paginationClickable: true,
        autoplayDisableOnInteraction: true
    });

}, 0);

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings