Hello,
I have repeater field with post object select and input.
On every post object selected i want to do ajax call, get something and put it in input in this row of repeater.
If i call:
var field = acf.getField('field_5f2b2cca23b7e');
field.on('change', function( e ){
service=field.val();
var fieldId=e.target.id;
var data = {
'action': 'get_service_price',
'service': service
};
$.ajax({
url: ajax_object.ajax_url,
type : 'post',
data: data,
dataType: 'json',
success: function( data ) {
console.log(data);
$('#'+fieldId+'').closest('.acf-row').find('.acf-field-5f2bb8a245508 input').val(data.price);
}
})
});
It only works for first row of repeater.
Any help would do…
Thanks
Hi! Did you already find a solution for this? I would be interested in more threads about repeater and AJAX. But to the point, I found this to work with repeater subfields.
// where field_609b103fcd576 is a sub-field in my repeater
acf.addAction("new_field/key=field_609b103fcd576", function ($field) {
$field.on("change", function (e) {
var value = $field.val();
console.log(value);
});
});
When tested on new or not-the-first repeater row this gave the correct value for each sub-field.