2012-03-06 87 views
0

我一直在嘗試使用JQuery UI,但似乎無法獲得任何工作方法。 我一直在試圖展示一個對話框,但沒有能夠做到這一點。 Jquery是workking。JQuery UI不起作用

我已經使用了Firebug,並且在加載jqueryUi時,jquery文件只是304沒有被修改的狀態,我沒有得到任何錯誤。

我不知道是否即時通訊做一些愚蠢的事或我還沒有安裝JQuery的UI右

任何幫助表示讚賞

繼承人的代碼,即時通訊使用

<html> 
<head> 
<link type="text/css" href="css/ui-lightness/jquery-ui-1.8.18.custom.css" 
    rel="stylesheet" /> 
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script> 
<script type="text/javascript" src="js/jquery-ui-1.8.18.custom.min.js"></script>  
<script type="text/javascript"> 
if (jQuery.ui) { 
alert("Success"); 
} 
$("#dlg_hello").dialog(); 

</script> 
</head> 
<body> 
<div id="dlg_hello">Hello World!</div> 
</body> 
</html> 

回答

3

你必須捕捉頁面加載事件來實例化一個jQuery UI對象。

試試這個:

$(document).ready(function(){ 
    $("#dlg_hello").dialog(); 
}); 

+0

哇感謝,一些愚蠢的 – jimmy 2012-03-06 15:34:16

+0

檢查出[手短版](http://stackoverflow.com/a/9586631/558021)太... – Lix 2012-03-06 15:36:38

+0

沒有問題,它總是哈哈 – tedski 2012-03-06 15:37:45

1

將您的文件準備包裝對話框

$(document).ready(function() { 
    // your code here 
}); 
1

嘗試你的代碼綁定到文檔準備事件,這樣

$(function(){ 
    if (jQuery.ui) { 
     alert("Success"); 
    } 
    $("#dlg_hello").dialog(); 
}); 
0

你s HOULD使用jQuery提供當框架已經成功加載到了解和準備使用的功能 -

<script type="text/javascript"> 
    $(function(){ 
    // now we know that jQuery has been loaded and is ready. 
    }); 
</script>