I'm currently experiencing problems with idangerous swiper. I use following libraries which are included in that order:
- jQuery 1.9.1
- jQuery Mobile 1.4.5
- Idangerous Swiper (jQuery) 3.0.6
Before adding the swiper to DOM via javascript I'm modifying it to fit my needs.
At the end following html code is generated which should match the needs of the api:
<div class="tx-cctest-pi1">
<div class="cctest-gallery-link" id="pageId-13">
<div class="swiper-13 swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide">
<img src="uploads/tx_cctest/bild1.jpg">
</div>
<div class="swiper-slide">
<img src="uploads/tx_cctest/bild2.jpg">
</div>
<div class="swiper-slide">
<img src="uploads/tx_cctest/bild3.jpg">
</div>
<div class="swiper-slide">
<img src="uploads/tx_cctest/bild4.jpg">
</div>
</div>
</div>
<div class="albumName">Architektur</div>
</div>
</div>
The code is generated dynamically and should generate multiple swipers (therefore the class name swiper-X).
The code for adding the swiper to the element is following one:
new Swiper('.swiper-'+ pageId, {
direction: 'horizontal',
loop: true,
preloadImages: true,
updateOnImagesReady: true,
grabCursor: true
});
There are no errors in the console, and the swiper does not swipe.
Update
Problem is solved. Checked back the code after enigma
prove that code seems to work fine without AJAX. As mentioned in the comment below the post of enigma
the problem was that the ajax call was not even done but the swiper was already created. So putting the Swiper construct within the done()
callback of the $.ajax
everything is working fine.
length: 0
although it is definitely in DOM (checked with Chrome developer tools). – thedompageId
is set correctly? – Gaelan