簡體   English   中英

在Wordpress上升級ACF之后,Onchange函數Javascript停止工作

[英]Onchange function Javascript stops working after ACF is upgraded on wordpress

升級ACF插件后,我的onchange函數JS文件在wordpress function.php上不再起作用。 我不知道發生了什么事。 這是我的代碼。 你能啟發我嗎?

irevent_script.JS

(function($) { 

     $('#acf-field-acf_event_type').on('change', function () {
     var selectVal = $("#acf-field-acf_event_type option:selected").val();

     if(selectVal=="Others") { 
        $("#title").val("");
     } else {
        $("#title").val(selectVal);
     }
});  
})( jQuery ); 



In function.php


function irevent_script( $hook_suffix ){
        $cpt = 'irevent';

        if( in_array($hook_suffix, array('post.php', 'post-new.php') ) ){
            $screen = get_current_screen();

            if( is_object( $screen ) && $cpt == $screen->post_type ){
                //wp_enqueue_script( 'tinymce_js', includes_url( 'js/tinymce/' ) . 'wp-tinymce.php', array( 'jquery' ), false, true );

                wp_enqueue_script('irevent_js_script', get_bloginfo('template_url').'/js/irevent_script.js', array('jquery'), '4.7.5', true);

            }
        }
    }

    add_action( 'admin_enqueue_scripts', 'irevent_script');

我發現ACF升級后,事件類型ID已更改。因此,我也必須在javascript中更改事件類型ID。 現在,它可以工作了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM