jQuery UI 和 jQuery 主题未加载时我遇到了一些问题。
我使用的是最新的 Wordpress 4.6。 在我的主题文件夹中使用 Functions.php,我添加了这段代码:
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 主题没有正确加载。 谢谢!
最佳答案
wp_enqueue_script('jquery-ui-checkboxradio');
我没有在引用中看到依赖关系 https://developer.wordpress.org/reference/functions/wp_enqueue_script/
不是吗
jquery-ui-button
或
jquery-ui-form
关于php - Wordpress 为前端主题 functions.php 包含 jQuery UI Checkboxradio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39975552/