jQuery Mobile Enqueue - 在 WordPress 管理中加载

标签 jquery wordpress mobile admin

我已经根据文档正确地将脚本排入队列,但 jquery mobile 仍在管理中加载。我的代码如下:

function mda_script_init() {
    if (!is_admin()) {
        wp_register_script( 'jquerypremobile', get_template_directory_uri() .'/library/js/jquery-pre-mobile.js', array( 'jquery' ), '1.0' );
        wp_enqueue_script( 'jquerypremobile' );
        wp_register_script( 'jquerymobile', 'http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js', array( 'jquery' ), '1.1.0' );
        wp_enqueue_script( 'jquerymobile' );
        wp_register_script( 'jqueryeffects', get_template_directory_uri() .'/library/js/jquery-effects.js', array( 'jquery' ), '1.0' );
        wp_enqueue_script( 'jqueryeffects' );
        wp_register_script( 'nwmatcher', 'http://s3.amazonaws.com/nwapi/nwmatcher/nwmatcher-1.2.5-min.js', false, '1.2.5' );
        wp_enqueue_script( 'nwmatcher' );
        wp_register_script( 'superfish', get_template_directory_uri() .'/library/superfish/supersubs.js', array( 'jquery' ), '1.4.8' );
        wp_enqueue_script( 'superfish' );
        wp_register_script( 'supersubs', get_template_directory_uri() .'/library/superfish/supersubs.js', array( 'jquery' ), '1.4.8' );
        wp_enqueue_script( 'supersubs' );    
    }
}
add_action('init', 'mda_script_init');

有人知道这是怎么回事吗?或者我做错了什么?

最佳答案

试试这个方法:

function mda_script_init() {
    wp_register_script( 'jquerypremobile', get_template_directory_uri() .'/library/js/jquery-pre-mobile.js', array( 'jquery' ), '1.0' );
    wp_enqueue_script( 'jquerypremobile' );
    // etc...
}
add_action('wp_enqueue_scripts', 'mda_script_init');

引用:http://codex.wordpress.org/Function_Reference/wp_enqueue_script

PS:WordPress 的具体问题最好放在这里:https://wordpress.stackexchange.com/

关于jQuery Mobile Enqueue - 在 WordPress 管理中加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10904590/

相关文章:

javascript - Jquery 2.1 - 单击时堆叠调用

javascript - Nativescript:如何从图库获取照片列表

mobile - html5 音频的 setVolume 在移动 Android 或 Safari 上不起作用 - 任何解决方法?

jquery - CSS 选择器对属性不区分大小写

Javascript 不会改变页面内容

javascript - PHP、Jquery、JS。 2个按钮在彼此身上,如何通过1次鼠标点击来点击它们?

php - 在wordpress中向tinyMCE添加内容

php - 自定义插件在激活插件后添加设置选项 URL

php - WordPress:以正确的顺序覆盖子主题中的多个 css 文件

javascript - Jquery 移动翻转切换从两个按钮中选择至少一个。