Home Forums Add-ons Repeater Field Javascript API acf.getField for repeater


Javascript API acf.getField for repeater

  • 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 ){
    		var data = {
    			'action': 'get_service_price',
    			'service': service    
    			url: ajax_object.ajax_url,
    			type : 'post',
    			data: data,
    			dataType: 'json',
    			success: function( 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…

  • 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();

    When tested on new or not-the-first repeater row this gave the correct value for each sub-field.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Javascript API acf.getField for repeater’ is closed to new replies.