2013-08-03 41 views
0

這段代碼有什麼問題?當我鍵入單詞時,建議不會以正確的形式出現。jquery autocomplete錯誤視圖

還有什麼我應該加載?

更新代碼: 找到了答案: `<鏈接相對

<!DOCTYPE html> 
<html> 
<head> 

<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 

</head> 
<body> 
<form> 
    <div class="list"> 
     <div class="item"> 
      <input type="hidden" class="user-id" id="h1"/> 
      <input type="text" class="user-name" id="t1"/> 
     </div> 
    </div> 
</form> 

<script> 
var users = [ 
    {"label":"User 1","value":"User 1","userId":1}, 
    {"label":"User 2","value":"User 2","userId":2} 
]; 

$(".user-name").autocomplete({ 
    source: users, 
    autoFocus: true, 
    delay: 0, 
}); 

</script> 
</body> 
</html> 
+0

只需要一行額外的代碼對我的作品=「stylesheet」type =「text/css」href =「http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css」>' – monjevin

回答

0

它添加

<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 

時看到此FIDDLE

+0

它在你的本地主機上工作嗎? – monjevin

+0

是的,它也適用於本地 – Gautam3164