Support

Account

Home Forums Front-end Issues Javascript API: Set data-conditions manually? Reply To: Javascript API: Set data-conditions manually?

  • You can do this using an acf/load_field or an acf/prepare_field filter. In either of these functions you can set the conditional logic and base it on any field using the field’s key.

    You could probably also do this using JavaScript by accessing the data value of the field. The value looks like a json encoded array. However I do not know if this will work, I don’t know it this need to be there before ACF initializes or not or if there is a way to reinitialize it if it does not.

    
    $('[data-key="YOUR FIELD KEY"]').data('conditions', 'JSON ENCODED ARRAY');