嗨,伙计们,我已经添加了jQuery和我的jQuery失败到我的主插件页面,它的工作很好,这是。
function load_scipt() {
wp_register_script( 'reserveit', plugins_url( '/js/reserveit.js', __FILE__ ), array( 'jquery' ), '2.5.1' );
wp_enqueue_script( 'reserveit' );
wp_register_script( 'datetimepicker', plugins_url( '/lib/datetimepicker/js/jquery-ui-timepicker-addon.js', __FILE__ ), array( 'jquery', 'jquery-ui-core', 'jquery-ui-slider', 'jquery-ui-datepicker' ) );
wp_enqueue_script( 'datetimepicker' );
wp_enqueue_script( 'jquery-ui-core' );
wp_enqueue_script( 'jquery-ui-datepicker' );
wp_enqueue_script( 'jquery-ui-slider' );
wp_enqueue_style( 'jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
}
add_action( 'wp_enqueue_scripts', 'load_scipt' );
Now I need to add jQuery datepicker to input in my admin menu, but it isn't working here is the code.
function load_scipts() {
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-datepicker' );
wp_enqueue_script( 'jquery-ui-core' );
wp_enqueue_script( 'jquery-ui-widget' );
wp_register_script( 'admin-menu', plugins_url( 'admin-menu.js', __FILE__ ), array( 'jquery', 'jquery-ui-datepicker' ), '2.5.1' );
wp_enqueue_script( 'admin-menu' );
wp_enqueue_style( 'jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css' );
}
add_action( 'wp_enqueue_scripts', 'load_scipts' );我什么都试过了,但都没用。我的路径文件工作,但我不知道问题在哪里。
这是我的reserveit.js
jQuery(文档).ready(函数($){
jQuery('#datepicker').datepicker({
dateFormat: 'dd-mm-yy'
});
});这是我的管理员
jQuery(document).ready(function(jQuery) {
jQuery('#datepicker').datepicker({
dateFormat: 'dd-mm-yy'
});
});如果你有想法,请写评论。
发布于 2013-12-18 14:59:24
如果您试图为管理请求登记脚本,则需要使用钩子admin_enqueue_scripts。wp_enqueue_scripts只适用于前端请求。
https://wordpress.stackexchange.com/questions/126867
复制相似问题