Home Forums Add-ons Repeater Field Hook to force repeater rows collapse on load


Hook to force repeater rows collapse on load

  • I have a page I’m creating with ACF that is using a repeater google map for map markers. Unfortunately the markers are getting a bit out of hand and it’s causing some browser lag due to 200+ Google maps trying to render in at once. Currently I went in to repeater.php and forced the -collapsed class to always return true, however is there a hook or action I can use to make them always collapsed on load?

    • James

    • March 15, 2016 at 5:36 pm

    Hi @jostrander

    I believe you can use the acf/input/admin_footer hook to add the collapse class to the field. It should be something like this:

    function my_acf_admin_footer() {
    	<script type="text/javascript">
        (function($) {
                $('.acf-field-1234567890 .acf-row').addClass( "-collapsed" );
                $('.acf-field-1234567890 .acf-field-abcdefghijklm').addClass( "-collapsed-target" );
                $('.acf-field-1234567890 .acf-field-abcdefghijklm').attr( "colspan", "2" );
    add_action('acf/input/admin_footer', 'my_acf_admin_footer');

    Where “1234567890” is the field key of your repeater field and “abcdefghijklm” is the field key of the subfield you want to show.

    I hope this helps. Thanks!

  • Hi James,

    the solution works great for me. Do you have any idea that nested repeater get expand by clicking on the parent repeater? That would be great.

    Thank you in advance

Viewing 3 posts - 1 through 3 (of 3 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.