Hi i have an issue on how to update fields on select change, in repeater fields using Javascript api.
I have and select object that pulls values from another post with Ajax and PHP, and i am getting values. But i would like to update fields, in my repeater fields in the row, with values. But i cannot target my fields, when select dropdown changes..
This is my code
$field.on("change", function(e) {
jQuery.ajax({
type: "POST",
dataType: 'text',
url: ajax_url,
data: {
action: 'call_update',
postId: value,
nonce: wp_nonce
},
success: function(response) {
data = JSON.parse(response);
success(data);
},
error: function(jqxhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
});
And in my success method i would like to update repeater fields
function success(data) {
var title = acf.getField('field_6144c465a849c');
title.val(data.title);
}
But how do i target subfields with javascript, i can only find how i target field by key, and then it updates all fields trough all repeater rows.
Regards Martin
What I have tried:
Tried to get fields by children in parent, and to use a filter method, acf own documentation is lagging on information on how to get subfields in repeater