在Index.cshtml,我有下面的代碼:在ASP.NET MVC使用Twitter Typehead
@{
ViewBag.Title = "Home Page";
}
<script type="text/javascript" src="http://twitter.github.io/typeahead.js/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://twitter.github.io/typeahead.js/releases/latest/typeahead.js"></script>
<script type="text/javascript" src="http://twitter.github.io/typeahead.js/js/hogan-2.0.0.js"></script>
<script src="../../Content/twitter/typeahead.min.js" type="text/javascript"></script>
<script type="text/javascript">
$('input.countries').typeahead({
name: 'countries',
local: ["Unites States", "Mexico", "Canada", "Cuba", "Guatemala"]
});
</script>
<input class="countries" type="text" placeholder="Countries">
但沒有自動完成建議....我只是跟隨第一2步在下面的鏈接做我的任務......
http://www.arungudelli.com/jquery/simple-jquery-autocomplete-search-tutorial/
有什麼幫助嗎?
如果您根據該頁面上的評論進行調整,這是否可行? 'input.countries'而不是'input.counties'? –
謝謝丹尼爾...絕對是錯誤的...我糾正了它。但是我仍然有同樣的問題 –
你是否包含typeahead.js庫文件?本教程沒有提到它,但沒有它,你不會走得很遠。 – Dhaulagiri