首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在主插件页中添加jQuery时,在仪表板中添加

在主插件页中添加jQuery时,在仪表板中添加
EN

WordPress Development用户
提问于 2013-12-18 10:37:47
回答 1查看 582关注 0票数 0

嗨,伙计们,我已经添加了jQuery和我的jQuery失败到我的主插件页面,它的工作很好,这是。

代码语言:javascript
复制
    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(函数($){

代码语言:javascript
复制
    jQuery('#datepicker').datepicker({
        dateFormat: 'dd-mm-yy'
    });

});

这是我的管理员

代码语言:javascript
复制
jQuery(document).ready(function(jQuery) {

    jQuery('#datepicker').datepicker({
        dateFormat: 'dd-mm-yy'
    });
});

如果你有想法,请写评论。

EN

回答 1

WordPress Development用户

回答已采纳

发布于 2013-12-18 14:59:24

如果您试图为管理请求登记脚本,则需要使用钩子admin_enqueue_scriptswp_enqueue_scripts只适用于前端请求。

票数 0
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/126867

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档