I am not understanding how to use the add_actions available found on https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/
I understand the inline and include option code but not the Actions
acf.add_action(‘ready’, function( $el ){
// $el will be equivalent to $(‘body’)
// find a specific field
var $field = $(‘#my-wrapper-id’);
// do something to $field
});`
does this go in the functions.php file or a separate jquery file. Any help would e appreciated!
This is javascript (or jQuery) and it goes in a custom javascript file or as inline script as described at the top of the page.
then I guess i am not understanding the acf.add_action. I understood add_actions are a WordPress php hook. How does this integrate with jquery?
acf.add_action
is something supplied by and for ACF. It is a JavaScript function that works in a similar way to the WP add_action function. It lets you add actions to ACF hooks that run in JavaScript.
This explanation was perfect and just what I needed!