jQuery Swiper script to run after Ng-Repeat elements are loaded

后端 未结 3 1330
甜味超标
甜味超标 2021-02-19 04:36

I\'m making a web app using AngularJS, jQuery, HTML, CSS and Bootstrap, and I would like to pick some image links from my JSON that is located in an Apache2 server and use them

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-19 05:37

    There's an even easier way you can use that's baked into Swiper.js. When you're initializing the swiper, just set the observer property to true. This will make Swiper watch for changes to your slides, so you won't have to worry about whether it runs before all the slides are added through ng-repeat.

    Example:

    var galleryTop = new Swiper('.gallery-top', { observer: true });

    And from the Swiper documentation on the observer property:

    Set to true to enable Mutation Observer on Swiper and its elements. In this case Swiper will be updated (reinitialized) each time if you change its style (like hide/show) or modify its child elements (like adding/removing slides)

提交回复
热议问题