【问题标题】:ACF Tag It Field and createTagACF Tag It Field 和 createTag
【发布时间】:2015-11-23 20:24:37
【问题描述】:

我在 ACF 中使用 Tag it Field add on,只想做最简单的事情,即使用 jQuery 添加标签。由于没有这方面的文档,我正在尝试使用 original jQuery plugin documentation 以及其中解释的方法以及 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 插件和/或 wordpress ACF add on implementation 的经验?

【问题讨论】:

    标签: jquery wordpress advanced-custom-fields tag-it


    【解决方案1】:

    代表我这是一个愚蠢的选择器错误。 Tag It ACF 插件将 tagit jquery 应用于输入而不是 ul。在我的情况下,我能够像这样访问元素并调用 tagit 功能:

    $( '#rhymes input.acf-tag-it', $el ).tagit( 'createTag', 'new tag' );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-27
      • 1970-01-01
      相关资源
      最近更新 更多