I’m using the Tag it Field add on for ACF and just want to do the simplest thing of adding a tag with jQuery. As there’s no documentation for this I’m trying to use the original jQuery plugin documentation and the methods explained there in conjunction with the wordpress ACF acf.add_action('load') hook.
I’m trying something like this in the wordpress theme's functions.php ( where rhymes is the tagit field’s wrapper id ) :
function my_acf_input_admin_footer()
{
?>
<script type="text/javascript">
(function($){
acf.add_action( 'load', function( $el ){
$( '#rhymes ul.tagit' ).tagit( 'createTag', 'example tag' );
});
})(jQuery);
</script>
<?php
}
add_action( 'acf/input/admin_footer', 'my_acf_input_admin_footer' );
It's just not doing anything, has anyone got any experience using the tagit jQuery UI plugin and/or the wordpress ACF add on implementation?
This was a silly selector mistake on my behalf. The Tag It ACF plugin applies the tagit jquery to an input and not a ul. In my case I was able to access the element and call tagit functionality like this:
$( '#rhymes input.acf-tag-it', $el ).tagit( 'createTag', 'new tag' );