Support

Account

Home Forums ACF PRO ACF Slider not firing in preview mode

Unread

ACF Slider not firing in preview mode

  • Hey peeps

    Hope you are all well

    I’ve built a custom block for a carousel, I have the block all working and the carousel working on the frontend.

    Only issue is, in preview mode in the editor, the init.js isn’t firing for the carousel.

    All the scripts are there, just not working in the admin, so the preview won’t show the carousel.

    My init.js file below.

    
    (function($){
    
        var initializeBlock = function( $block ) {
            $(".owl-carousel").owlCarousel({
                  margin: 10,
                  nav: true,
                  navText: '',
                  loop: true,
                  autoHeight:false,
                  responsive: {
                    0: {
                      items: 1
                    },
                    768: {
                      items: 2
                    },
                    1024: {
                      items: 3
                    }
                  }
            });
        }
    
        // Initialize each block on page load (front end).
        $(document).ready(function(){
          initializeBlock();
        });
    
        // Initialize dynamic block preview (editor).
        if( window.acf ) {
            window.acf.addAction( 'render_block_preview/type=owl-carousel', initializeBlock );
        }
    
    })(jQuery);
    
    
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.