我有一个jQuery UI和jQuery主题不加载的问题。
我使用的是最新的Wordpress 4.6。使用我的主题文件夹中的Functions.php,ive添加了以下代码:
function jquery_frontend_scripts() {
global $wp_scripts;
wp_enqueue_script('jquery-core');
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-ui-checkboxradio');
$queryui = $wp_scripts->query('jquery-ui-core');
$url = "//ajax.googleapis.com/ajax/libs/jqueryui/".$queryui->ver."/themes/base/jquery-ui.css";
wp_enqueue_style('jquery-ui-base', $url, false, null);
}
if (!is_admin()) add_action('wp_enqueue_scripts', 'jquery_frontend_scripts');在wordpress管理员的contact7页面上,添加了:
<script>
jQuery(function() {
jQuery( "input" ).checkboxradio({
icon: false
});
} );
</script>
<legend>Välj belopp: </legend>
<label for="radio-50">50 kr</label>
<input type="radio" name="radio-50" id="radio-50">
<label for="radio-200">200 kr</label>
<input type="radio" name="radio-200" id="radio-200">
<label for="radio-500">500 kr</label>
<input type="radio" name="radio-500" id="radio-500">该函数正在被调用。所以我猜一定是jQuery UI或者jQuery主题没有正确加载的问题。谢谢!
发布于 2017-05-14 22:17:35
wp_enqueue_script('jquery-ui-checkboxradio');
我在引用https://developer.wordpress.org/reference/functions/wp_enqueue_script/中看不到依赖关系
不是吗?
jquery-ui-按钮
或
jquery-ui-表单
发布于 2016-10-11 19:06:53
您是否尝试过指定脚本的源,将其作为函数wp_enqueue_script的第二个参数传递
请参阅documentation。
发布于 2016-12-06 02:28:48
我来晚了一点,但是如果你没有找到答案,你的jquery-ui "base“样式的url是不正确的。wordpress中jquery ui的当前版本是1.11.4。如果你去//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/base/jquery-ui.css,,你会得到404分。我没有看到基本样式在1.11.4版的http://code.jquery.com/ui/中可用,但它在1.12.1版中可用。因此,我建议选择不同的样式,或者看看最新稳定版本的基本样式是否有效。
https://stackoverflow.com/questions/39975552
复制相似问题