ACF Tag It Field 和 createTag
ACF Tag It Field and createTag
我正在使用 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。
我在 wordpress 主题的 functions.php 中尝试类似的东西(其中押韵是 tagit 字段的包装器 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' );
它什么也没做,有没有人有使用 tagit jQuery UI 插件 and/or wordpress ACF 附加实现的经验?
对我而言,这是一个愚蠢的选择器错误。 Tag It ACF 插件将 tagit jquery 应用于输入而不是 ul。在我的例子中,我能够像这样访问元素并调用 tagit 功能:
$( '#rhymes input.acf-tag-it', $el ).tagit( 'createTag', 'new tag' );
我正在使用 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。
我在 wordpress 主题的 functions.php 中尝试类似的东西(其中押韵是 tagit 字段的包装器 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' );
它什么也没做,有没有人有使用 tagit jQuery UI 插件 and/or wordpress ACF 附加实现的经验?
对我而言,这是一个愚蠢的选择器错误。 Tag It ACF 插件将 tagit jquery 应用于输入而不是 ul。在我的例子中,我能够像这样访问元素并调用 tagit 功能:
$( '#rhymes input.acf-tag-it', $el ).tagit( 'createTag', 'new tag' );