O
O
Orkhan Hasanli2018-07-29 20:25:19
JavaScript
Orkhan Hasanli, 2018-07-29 20:25:19

Why is flexslider 2 initialization inside ACF Repeater not working?

Hello!
Created ACF repeater with Gallery field type. For each gallery flexslider 2 should be displayed. But the slider is shown only for the first gallery.
Slider link - flexslider.woothemes.com Slider
initialization code:

jQuery(window).on('load', function() {
// flexslider android
      jQuery('#carousel_android').flexslider({
      animation: "slide",
      animationLoop: true,
      itemWidth: 150,
      itemMargin: 10,
    maxItems: 4,
    slideshowSpeed: 4000,
    controlNav: true 
    });
});

Repeater code with slider:
<?php if( have_rows('android_os') ): 
while ( have_rows('android_os') ) : the_row(); ?>

                  <?php 
                  $images = get_sub_field('android_screenshots');
                  $size = 'md7_blog';

                  if( $images ): ?>
                    <div id="carousel_android" class="flexslider">
                    		<ul class="slides">
                          <?php foreach( $images as $image ): ?>
                              <li>
                              	<?php echo wp_get_attachment_image( $image['ID'], $size ); ?>
                              </li>
                          <?php endforeach; ?>
                      	</ul>
                      </div>
                  <?php endif; ?>
                    </div>  
                     
            <?php endwhile;
              else :
                  // no rows found
              endif; ?>

As a result, the slider is initialized for the first element. For the second and subsequent sliders are not displayed. There are no errors in the console. When inspecting an element, I see a ul list with li elements and with the property display:none

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alex, 2018-07-29
@azerphoenix

jQuery('#carousel_android').flexslider({...}); // неправильно
jQuery('.flexslider').flexslider({...}); // правильно

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question