2014-03-12 142 views
0

嗨我新J查詢,並試圖讓我的文本框之一自動完成 這裏是asp x頁面的代碼。Jquery自動完成 - 對象[對象對象]沒有方法'自動完成'

<asp:Content ID="Content2" 
ContentPlaceHolderID="head" Runat="Server"> <title>jQuery UI 
Autocomplete - Default functionality</title> <link rel="stylesheet" 
href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> 
<script src="//code.jquery.com/jquery-1.9.1.js"></script> <script 
src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <link 
rel="stylesheet" href="/resources/demos/style.css"> <script> 
     $(function() { 
      var availableTags = [ 
     "ActionScript", 
     "Apple-script", 
     "Asp", 
     "BASIC", 
     "C", 
     "C++", 
     "Closure", 
     "COBOL", 
     "ColdFusion", 
     "Erlang", 
     "Fortran", 
     "Groovy", 
     "Haskell", 
     "Java", 
     "JavaScript", 
     "Lisp", 
     "Perl", 
     "PHP", 
     "Python", 
     "Ruby", 
     "Scala", 
     "Scheme" 
    ]; 
      $("#tags").autocomplete({ 
       source: availableTags 
      }); 
     }); </script> </asp:Content> 

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" 
Runat="Server"> <div id="searchcontainer" style="margin-top:50px"> 
<div class="ui-widget"> <label for="tags">Tags: </label> <input 
id="tags"> </div> 
    <input id="btnSearch" type="button" value="Search" style="margin-left:30px;border-radius: 5px; height: 30px; width:150px; 
box-shadow:3px 3px 3px #888888 ;" /> 
    <input id="btnCancel" type="button" value="Cancel" style="margin-left:30px;border-radius: 5px; height: 30px; width:150px; 
box-shadow:3px 3px 3px #888888 ;" /> </div> <div id="grdDisp" 
style="margin-top:30px"> 
    <asp:GridView ID="grdPurchaseHist" AllowPaging="true" CssClass="EU_DataTable" PageSize="10" 
OnPageIndexChanging="grdPurchaseHist_PageIndexChanging" 
     runat="server" > 
    </asp:GridView> </div> </asp:Content> 

怎麼過,當我在瀏覽器中查看此頁它不工作,它的控制檯,它說 對象對象有沒有方法「自動完成」。 我試過在沒有內容頁面的新頁面中引用的類似.js文件只是爲了測試它,它工作正常。另外,當添加日期選擇器UI時,它在上述頁面上工作時,從提到的相同的.js文件引用。

所以我不知道我在這個Web窗體或.js文件中做了什麼錯誤,因爲自動完成的用戶界面不工作,並且找不到方法。 請幫忙.. 在此先感謝..

回答

0

我不確定您的網頁出了什麼問題。除了在輸入標記上缺少結束標記,每件事情似乎都已到位。

<input id="tags"> should be <input id="tags" /> 

大多數瀏覽器雖然寬容,你可能會得到這個方式。

我試了一下你的代碼,它的工作原理。我已經爲你編譯了一個示例項目here,並確保你有一個使用母版頁的類似設置。

+0

非常感謝您的回覆。事實上,我得到了什麼問題,您的項目對我來說工作正常,但在我的情況下,我的母版頁引用了一些舊的和衝突的其他.js文件,因此刪除了它們,並且都變得棒極了。 。 – user3409108

相關問題