Support

Account

Home Forums Add-ons Repeater Field Add row to repeater field with js? Reply To: Add row to repeater field with js?

  • Hi Pete, it’s been a while and I never fully used this functionality. I think I only figured out how to add a repeater row with Jquery. The problem was that removing the row triggers a confirmation dialogue box, which you also would have to ‘click’ using JS.

    
        // Add data to ACF field with Jquery
        (function($){
            if (typeof(acf) == 'undefined') { return; }
    
            var repeatDiv = document.querySelector('.acf-field-asdfkey');
            var addRow = repeatDiv.querySelector('.acf-button');
            addRow.click();
            var field = acf.getFields({
                key: 'field_asdfkey'
            });
            field.slice(-1)[0].val(gridArea);
        })(jQuery); }
    

    I don’t really know if this code still works, but it’s all I have. Hope it can be of help.