2013-03-11 108 views
3

我想添加一個簡單的進度條到我的應用程序在rails中使用jquery-ui。我下面這個例子:http://jqueryui.com/progressbar/jquery-ui進度條沒有顯示

我創建的div

<div id="progressbar"></div> 

,在我的JS我有

$(document).ready(function() { 
    $("#progressbar").progressbar({ 
    value: 37 
    }); 
}); 

但什麼也沒有發生在HTML股利 - 它仍然是空的,無風格(即沒有額外的CSS應用於它)。

我檢查了我的應用程序中包含jquery-ui - 特別是,我已經確定包含jquery-ui css文件。

不過,我願意打賭這個問題有事情做與jQuery UI的不是我的應用程序正常工作,因爲我是有它的另一個問題和提示功能,我問了一下在這裏:positioning jQuery tooltip

這使我瘋狂,有沒有人有任何想法?

+1

「不顯示」不足以幫助您。元素是否存在於DOM中?顯示器是否設置爲無?有沒有JavaScript錯誤? – 2013-03-11 20:35:32

+0

你可以發佈你的進度條div的代碼嗎? – 2013-03-11 20:43:09

回答

0

我現在有同樣的問題。

看起來好像在示例中引用的庫文件不起作用。
錯誤我從一開始 「火狐 - 開發工具 - 瀏覽器控制檯」 是:

ReferenceError: $ is not defined

(我在Firefox 32.0.3和IE 11測試)如果你只是拷貝例如HTML/jquery源文件從「http://jqueryui.com/progressbar/」複製到本地文件(我們稱之爲:「testJqueryProgressBar.html」)並雙擊它,您將看到沒有進度條!

「testJqueryProgressBar.html」的來源:

<!doctype html> 
<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <title>jQuery UI Progressbar - Default functionality</title> 
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"> 
    <script src="//code.jquery.com/jquery-1.10.2.js"></script> 
    <script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script> 
    <link rel="stylesheet" href="//jqueryui.com/resources/demos/style.css"> 
    <script> 
     $(function() 
     { 
      $("#progressbar").progressbar({ value: 37 }); 
     }); 
    </script> 
</head> 
<body> 
    <div id="progressbar"></div> 
</body> 
</html> 

因此我檢查了鏈接在該示例的標頭和所有參考的東西。 所以這些鏈接是有效的!

我甚至試圖從另一個提供者f.e.中引用jquery庫。 :https://developers.google.com/speed/libraries/devguide?hl=de#jquery-ui。 同樣的問題!

然後我去http://jqueryui.com/download/ 選定的版本:1.11.1(穩定,爲jQuery1.6 +) 選擇了不同的UI主題底部

下載的ZIP和我的本地引用這些解壓的jQuery的來源例如testJqueryProgressBar.html,它的工作。