[英]Onchange function Javascript stops working after ACF is upgraded on wordpress
After I have upgraded ACF plugin, My onchange function JS file is not working anymore on wordpress function.php. 升级ACF插件后,我的onchange函数JS文件在wordpress function.php上不再起作用。 I don't know what happened to it.
我不知道发生了什么事。 Here is my code.
这是我的代码。 Could you please enlighten me?
你能启发我吗?
irevent_script.JS 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');
I found that event type ID has been changed after ACF upgraded.So, I had to change event type ID in javascript as well. 我发现ACF升级后,事件类型ID已更改。因此,我也必须在javascript中更改事件类型ID。 Now, it works.
现在,它可以工作了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.