我了解如何在jQuery中定期对functions.php UI进行排队。
我的问题是,我使用的选择菜单小部件在默认情况下不随WordPress一起使用:
http://wiki.jqueryui.com/w/page/12138056/Selectmenu
...and只有当我使用以下方法对jQuery进行排队时才能工作:
wp_enqueue_script(
'uicore',
'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js',
array('jquery')
);这不与数据编辑器冲突,但我一调用jQuery UI按钮,页面上的所有jQuery元素就会中断。
按钮、选择菜单和数据采集器协同工作的测试示例:http://www.dominornovus.com/jquery-test-environment/
调用按钮破坏所有jQuery元素的实际示例:http://www.dominornovus.com/killyliss-country-house/test/
//wp_enqueue_script('jquery-ui-datepicker');
//wp_enqueue_script('jquery-ui-button');
//wp_enqueue_style( 'uicss', 'http://dominornovus.com/wp-content/themes/killylisscountryhouse/jquery/custom-theme/custom-killyliss.css' );
//wp_enqueue_script( 'uisel', 'http://jquery-ui.googlecode.com/svn/branches/labs/selectmenu/ui.selectmenu.js' );
//wp_enqueue_style( 'uicss2', 'http://jquery-ui.googlecode.com/svn/branches/labs/selectmenu/ui.selectmenu.css' );
add_action('wp_enqueue_scripts','enq_menu_scripts_and_styles');
function enq_menu_scripts_and_styles() {
// UI Core, loads jQuery as a dependancy
wp_enqueue_script(
'uicore',
'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js',
array('jquery')
);
// jQuery
//wp_enqueue_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"' );
// jQuery UI
//wp_enqueue_script( 'jqueryui', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js' );
// UI Theme CSS
//wp_enqueue_style( 'uicss', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css' );
wp_enqueue_style( 'uicss', 'http://dominornovus.com/wp-content/themes/killylisscountryhouse/jquery/custom-theme/custom-killyliss.css' );
// Datepicker JS
//wp_enqueue_script('jquery-ui-datepicker');
//wp_enqueue_script( 'uidate', 'http://jquery-ui.googlecode.com/svn/branches/1.7.3/ui/ui.datepicker.js' );
// Button JS
//wp_enqueue_script('jquery-ui-button');
//wp_enqueue_script( 'uibutton', 'http://jquery-ui.googlecode.com/svn/branches/1.7.3/ui/ui.button.js' );
// Selectmenu JS
wp_enqueue_script( 'uisel', 'http://jquery-ui.googlecode.com/svn/branches/labs/selectmenu/ui.selectmenu.js' );
// Selectmenu CSS
wp_enqueue_style( 'uicss2', 'http://jquery-ui.googlecode.com/svn/branches/labs/selectmenu/ui.selectmenu.css' );
}任何帮助都将不胜感激。
发布于 2012-09-04 11:52:45
很可能你的测试因为冲突而失败了。实际上,您正在加载所有UI脚本的两个版本。这是因为Google版本的JQuery UI不是核心,而是整个脚本库(包括datepicker、autocomplete等),而不是WordPress脚本,后者在管理区域内往往会被连接起来。
这意味着,如果您包含Google的版本,则不必单独排列所有UI脚本。他们只会起作用。先试试。
如果您发现其他东西(WP、插件、来自主题的元素)正在为WP的默认脚本排队并造成麻烦,您可以尝试将那些引起冲突的脚本排出队列(只需查看测试页面的底部:它们都在那里)。或者您可以尝试用CDN脚本替换WP脚本的官方方法,如“法典”所述。
// Deregister first, then register again with new source, and enqueue
wp_deregister_script('jquery-ui-core');
wp_register_script('jquery-ui-core', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js');
wp_enqueue_script('jquery-ui-core');这里的问题是依赖关系。您可能必须与其他UI脚本一起执行此操作,以使其按预期工作。
最后但并非最不重要的是,我听说WP3.5默认包含最新版本的UI (截至今天为1.8.23)。虽然我不能说如果您现在使用3.5 alpha,您就不会有其他问题,但是您可能不会遇到脚本队列冲突。
https://wordpress.stackexchange.com/questions/64062
复制相似问题