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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.