繁体   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