2016-10-11 30 views
2

我有一個jQuery UI的問題& jQuery主題不加載。WordPress的前端主題包括jQuery UI Checkboxradio functions.php

即時通訊使用最新的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'); 

在一個contact7頁面內WordPress管理香港專業教育學院補充說:

<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 Theme不能正確加載會出現問題。 謝謝!

回答

0

您是否嘗試過指定腳本的來源,並將其作爲函數wp_enqueue_script的第二個參數傳遞?

查看documentation

+0

謝謝!我只是試了一下,但沒有效果:( With:'wp_enqueue_script('jquery','//code.jquery.com/jquery-3.1.1.min.js');和wp_enqueue_script('jquery-ui-core ','//code.jquery.com/ui/1.12.1/jquery-ui.min.js');' –

0

我有點晚了,但萬一你沒有找到答案,你的url爲jquery-ui「base」風格是不正確的。 jQuery UI在WordPress的當前版本是1.11.4。如果您訪問//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/base/jquery-ui.css,則會得到404。我看不到基礎樣式可通過http://code.jquery.com/ui/版本爲1.11.4,但可用於版本1.12.1。所以我會建議選擇不同的風格,或者看看基礎風格的最新穩定版本是否工作。

相關問題